public class TransactionAwareEventPublisher extends DelegatingMultiEventPublisher implements com.atlassian.event.api.EventPublisher, MultiEventPublisher
Note that any transactional operations done in afterCommit(), need to be wrapped in a PROPAGATION_REQUIRES_NEW transaction,
(see TransactionSynchronization.afterCommit()
). This is guaranteed by
TransactionAwareEventDispatcher
Since publishing an event during a transaction causes a TransactionSynchronization
to be registered for cases where many events are sent at once, it makes sense to use publishAll(Collection)
, to wrap them
in a single TransactionSynchronization, as transaction performance degrades notably with the number of distinct synchronizations registered.
delegate
Modifier and Type | Method and Description |
---|---|
void |
publish(Object event) |
void |
publishAll(Collection<Object> events)
Publish events that will be consumed by their respective registered listeners.
|
register, unregister, unregisterAll
public void publish(Object event)
publish
in interface com.atlassian.event.api.EventPublisher
publish
in class DelegatingMultiEventPublisher
public void publishAll(Collection<Object> events)
MultiEventPublisher
EventPublisher.publish(Object)
for every event in the collection.publishAll
in interface MultiEventPublisher
publishAll
in class DelegatingMultiEventPublisher
Copyright © 2021 Atlassian. All rights reserved.