I think you can use write through approach to update your third Cache "C".

Implement CacheStore interface or extend CacheStoreAdapter class and
override write/writeAll and delete/deleteAll methods. These methods will be
invoked by ignite when you do commit on ignite transaction. If only one
cache entry is updated or deleted, write or delete method will be invoked.
If more than one cache entries are updated, writeAll or deleteAll method
will be invoked on commit. In write/writeAll and delete/deleteAll method
you can write a simple producer code which will write the updated entries
of cache A and Cache B to some message queue in a single transaction. So if
the transaction is rolled back, all the cache entries written to message
queue (e.g. Kafka topic or any jms queue ) will be rolled back.

You can plug any messaging mechanism's dat source using
CacheStoreSessionListener interface. Just implement this interface and
override onSessionStart and onSessionEnd methods. In onSeesionStart method
you need to attach messaging mechanism connection to session and in
onSessionEnd method you need to commit or rollback. Please
check CacheStoreSessionListener class and you will understand what I am
trying to say.

In short you can use writethrough mechanism to write your cache events to
messaging queue.
You can write a simple listener which will listen to this queue and read
the cache events and do the cache updates in cache C.

Thanks,
PRasad


On Sat, Jul 14, 2018 at 9:18 AM xero <[email protected]> wrote:

> Hi,
> Do you know if there is mechanism to subscribe for to transaction events
> (pre or post commit)?
>
> My scenario is the following:
> I have 2 caches (A and B) that are modified in the same transaction. On the
> other hand, I have a third C cache whose entries are calculated based on A
> and B values.
> I would like to update C once the transaction that modifies A and B
> commits.
>
> I plan to collect the modifications of A and B caches by subscribing to the
> events (which have the associated transaction id  in the cix field). I
> would
> like to group all the events associated with a certain cix but, I can not
> find a way to hook to the transaction's commit event in order to ensure
> that
> all the cache events were triggered.
> Then, if the tx modified 5 entries in A and 5 entries in B, I would like to
> group them once I have collected all 10 events.
>
> Any help would be greatly appreciated
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Reply via email to