Search in sources :

Example 1 with TransactionRolledBackEvent

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

the class AbstractEventsService method afterRollback.

@Override
public void afterRollback() {
    String txnId = AlfrescoTransactionSupport.getTransactionId();
    long timestamp = System.currentTimeMillis();
    String networkId = TenantUtil.getCurrentDomain();
    String username = AuthenticationUtil.getFullyAuthenticatedUser();
    Client alfrescoClient = getAlfrescoClient(null);
    Event event = new TransactionRolledBackEvent(nextSequenceNumber(), txnId, networkId, timestamp, username, alfrescoClient);
    if (logger.isDebugEnabled()) {
        logger.debug("sendEvent " + event);
    }
    try {
        messageProducer.send(event);
    } catch (MessagingException e) {
        // throw new AlfrescoRuntimeException("Failed to send event", e);
        // TODO just log for now. How to deal with no running ActiveMQ?
        logger.error("Failed to send event " + event, e);
    } finally {
        TxnEvents events = (TxnEvents) AlfrescoTransactionSupport.getResource(EVENTS_KEY);
        if (events != null) {
            events.clear();
        }
    }
}
Also used : MessagingException(org.gytheio.messaging.MessagingException) 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) TransactionRolledBackEvent(org.alfresco.sync.events.types.TransactionRolledBackEvent)

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 MessagingException (org.gytheio.messaging.MessagingException)1