I think you don't have to do anything extra to group all events for same transaction. It doesn't not matter how many caches you are updating in single transaction. Let's assume that you are updating 10 caches in single transaction. When you do commit, your all 10 cache store's writeAll or deleteAll methods will be invoked. These writeAll and deleteAll methods will get all your cache updates entries (cache events ) as method parameters. Just put all these events on queue/topic. As these methods are invoked as a result of commit operation, you can be sure that you have collected all cache events.
All though each cache configuration has it's own CacheStoreSessionListener, I think it should not be a problem. Ignite might be managing it internally. Can you please do a small poc to check this? Just write all cache events to some queue and throw some runtime exception from one of you cachestore just to make sure that transaction is rolledback and nothing is published on queue. Similarly do successful commit and see if you can get all cache events in your message listener/consumer. Thanks, Prasad On Sun, Jul 15, 2018, 11:01 PM xero <[email protected]> wrote: > Thanks for replying PRasad, > I understand your approach but, I still don't get /when/ I should group all > events for the same transaction. In my tests I get onSessionStart and > onSessionEnd for each cache (both sharing the same cix). I would love to > have a post commit hook because at that point I'm sure that I have > collected > all the events. (In this example I have A and B caches but, in reality > could > have multiple of them). > > Example implementing CacheStoreSessionListener to log events: > em.getTransaction().begin(); > A a = new A(); > a.setData(10); > em.persist(a); > > b b = new b(); > b.setIntData(20); > em.persist(b); > > em.getTransaction().commit(); > > Triggered events: > OnSessionStart cacheName:a_entity > xid:e1fceee9461-00000000-0888-5e7a-0000-000000000001 > OnSessionStart cacheName:b_entity > xid:e1fceee9461-00000000-0888-5e7a-0000-000000000001 > OnSessionEnd cacheName:a_entity > xid:e1fceee9461-00000000-0888-5e7a-0000-000000000001 commit:true > OnSessionEnd cacheName:b_entity > xid:e1fceee9461-00000000-0888-5e7a-0000-000000000001 commit:true > > > Is there a way of getting only one onSessionEnd event? or getting an event > associated with the transaction? > > Thanks! > > > > -- > Sent from: http://apache-ignite-users.70518.x6.nabble.com/ >
