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();
}
}
}
Aggregations