Re: Database transaction updating more than 1 table from CacheStore

2016-04-19 Thread vkulichenko
Binti,

Session listener is just a callback that is called before and after cache
transaction. In case of write-through you can use it to start and
commit/rollback DB transaction along with cache transaction. With
write-behind it doesn't help much because in this case DB is updated from
primary nodes and generally there are several of them in one transaction,
which makes maintaining a single DB transaction impossible. The only way to
fully guarantee transactional consistency is using write-through.

-Val



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Database-transaction-updating-more-than-1-table-from-CacheStore-tp4197p4344.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Database transaction updating more than 1 table from CacheStore

2016-04-19 Thread bintisepaha
We do not want to use write-through, because database slowness is the reason
why we are using ignite grid. Write-behind is our choice. But since we want
a few tables to be updated in one DB transaction, it looks like the only way
to achieve this is our own CacheStore implementation on the main cache and
use that to get rows from other caches (they are all linked to a key) and
then update in a single DB transaction. the other caches don't have to
implement write-through.

Is there any better way to achieve this? Can CacheJdbcStoreSessionListener
or a similar implementation achieve what we are trying to do? Not fully
understanding what CacheJdbcStoreSessionListener does.

Thanks,
Binti





--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Database-transaction-updating-more-than-1-table-from-CacheStore-tp4197p4332.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Database transaction updating more than 1 table from CacheStore

2016-04-15 Thread vkulichenko
The example I provided [1] has this, see line 90. Out of the box Ignite
provides JDBC-based CacheJdbcStoreSessionListener, Spring-based
CacheSpringStoreSessionListener and Hibernate-based
CacheHibernateStoreSessionListener. These three fit majority of cases, but
you're always free to implement your own.

There is a lack of documentation on this matter and I will try to add it
soon. In the meantime, feel free to ask any questions.

-Val



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Database-transaction-updating-more-than-1-table-from-CacheStore-tp4197p4239.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Database transaction updating more than 1 table from CacheStore

2016-04-15 Thread bintisepaha
Val, is there an example of how to use Cache store sessions listeners?



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Database-transaction-updating-more-than-1-table-from-CacheStore-tp4197p4238.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Database transaction updating more than 1 table from CacheStore

2016-04-14 Thread vkulichenko
Hi Binti,

Can you please properly subscribe to the mailing list so that the community
can receive email notifications? Here is the instruction:
http://apache-ignite-users.70518.x6.nabble.com/mailing_list/MailingListOptions.jtp?forum=1


bintisepaha wrote
> We have a use case where multiple database tables/caches need to updated
> within a transaction, on the cluster side I can achieve this using
> IgniteTransactions. But I want to do the same while its going to the DB
> Store using write-behind. Seems like CacheStoreSession is something I
> should be using, but I could not find examples that wrote to 2 tables
> together in a transaction. Does ignite have some way to chain this when
> writing to the database or does this have to be a custom cacheStore
> implementation?
> 
> table A -> cache A
> table B -> cache B
> 
> But when A is updated, B is always updated (ignite transaction). How can
> write-behind achieve this?

This is possible only with write-through with the help of cache store
session listeners. See store example [1] on how it is used.

With write-behind database is updated asynchronously, so the DB updates are
independent and can't be enlisted in a single DB transaction.

[1]
https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Database-transaction-updating-more-than-1-table-from-CacheStore-tp4197p4202.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.