Search in sources :

Example 1 with TransactionCommittedEvent

use of org.alfresco.sync.events.types.TransactionCommittedEvent in project alfresco-repository by Alfresco.

the class AbstractEventsService method afterCommit.

@Override
public void afterCommit() {
    if (sendEventsBeforeCommit) {
        if (!shouldSendCommitEvent()) {
            return;
        }
        // send txn committed event
        String txnId = AlfrescoTransactionSupport.getTransactionId();
        long timestamp = System.currentTimeMillis();
        String networkId = TenantUtil.getCurrentDomain();
        String username = AuthenticationUtil.getFullyAuthenticatedUser();
        Client alfrescoClient = getAlfrescoClient(null);
        final Event event = new TransactionCommittedEvent(nextSequenceNumber(), txnId, networkId, timestamp, username, alfrescoClient);
        if (logger.isDebugEnabled()) {
            logger.debug("sendEvent " + event);
        }
        // Need to execute this in another read txn because Camel/JMS expects it (the config now seems to
        // require a txn)
        transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

            @Override
            public Void execute() throws Throwable {
                messageProducer.send(event);
                return null;
            }
        }, true, false);
    } else {
        // send all events
        final TxnEvents transactionEvents = (TxnEvents) AlfrescoTransactionSupport.getResource(EVENTS_KEY);
        if (transactionEvents != null) {
            List<Event> filteredEvents = filterEventsBeforeSend(transactionEvents.getEvents());
            updateTransactionEvents(transactionEvents, filteredEvents);
            transactionEvents.sendEvents();
        }
    }
}
Also used : TransactionCommittedEvent(org.alfresco.sync.events.types.TransactionCommittedEvent) TransactionRolledBackEvent(org.alfresco.sync.events.types.TransactionRolledBackEvent) Event(org.alfresco.sync.events.types.Event) TransactionCommittedEvent(org.alfresco.sync.events.types.TransactionCommittedEvent) Client(org.alfresco.sync.repo.Client)

Aggregations

Event (org.alfresco.sync.events.types.Event)1 TransactionCommittedEvent (org.alfresco.sync.events.types.TransactionCommittedEvent)1 TransactionRolledBackEvent (org.alfresco.sync.events.types.TransactionRolledBackEvent)1 Client (org.alfresco.sync.repo.Client)1