Search in sources :

Example 1 with TransactionCompleted

use of org.infinispan.notifications.cachelistener.annotation.TransactionCompleted in project infinispan by infinispan.

the class RemoteClusterListener method transactionCompleted.

@TransactionCompleted
public CompletionStage<Void> transactionCompleted(TransactionCompletedEvent event) {
    GlobalTransaction transaction = event.getGlobalTransaction();
    Queue<CacheEntryEvent> events = transactionChanges.remove(transaction);
    if (event.isTransactionSuccessful() && events != null) {
        List<ClusterEvent> eventsToSend = new ArrayList<>(events.size());
        for (CacheEntryEvent cacheEvent : events) {
            eventsToSend.add(ClusterEvent.fromEvent(cacheEvent));
            // Send event back to origin who has the cluster listener
            if (log.isTraceEnabled()) {
                log.tracef("Passing Event(s) to manager %s to send to %s", eventsToSend, origin);
            }
        }
        eventManager.addEvents(transaction, origin, id, eventsToSend, sync);
    }
    return CompletableFutures.completedNull();
}
Also used : ArrayList(java.util.ArrayList) GlobalTransaction(org.infinispan.transaction.xa.GlobalTransaction) CacheEntryEvent(org.infinispan.notifications.cachelistener.event.CacheEntryEvent) TransactionCompleted(org.infinispan.notifications.cachelistener.annotation.TransactionCompleted)

Aggregations

ArrayList (java.util.ArrayList)1 TransactionCompleted (org.infinispan.notifications.cachelistener.annotation.TransactionCompleted)1 CacheEntryEvent (org.infinispan.notifications.cachelistener.event.CacheEntryEvent)1 GlobalTransaction (org.infinispan.transaction.xa.GlobalTransaction)1