public class EventTemplate extends Object
EventBus
, taking active
UnitOfWork into account. When a UnitOfWork is active, the template will ensure correct ordering with any other
events published during the course of that UnitOfWork. If no unit of work is active, the Event is published
immediately to the Event Bus.
Messages sent with this template will have the current thread's correlation data in its meta data.
The template also allows addition of Meta Data properties to all Events sent through this template.CorrelationDataHolder
Constructor and Description |
---|
EventTemplate(EventBus eventBus)
Initialize the template to publish Events through the given
eventBus . |
EventTemplate(EventBus eventBus,
Map<String,?> additionalMetaData)
Initialize the template to publish Events through the given
eventBus . |
Modifier and Type | Method and Description |
---|---|
void |
publishEvent(Object payload)
Publishes an event with given
payload on the configured Event Bus. |
void |
publishEvent(Object payload,
Map<String,?> metaData)
Publishes an event with given
payload on the configured Event Bus, with given metaData
attached. |
public EventTemplate(EventBus eventBus)
eventBus
.eventBus
- The EventBus to publish Event Messages on.public EventTemplate(EventBus eventBus, Map<String,?> additionalMetaData)
eventBus
. The given
additionalMetaData
is attached to all events published through this instance.eventBus
- The EventBus to publish Event Messages on.additionalMetaData
- The meta data to add to messages sentpublic void publishEvent(Object payload)
payload
on the configured Event Bus.
This method takes into account that a Unit of Work may be active, using that Unit of Work to ensure
correct publication of the event.payload
- The payload of the event to publishpublic void publishEvent(Object payload, Map<String,?> metaData)
payload
on the configured Event Bus, with given metaData
attached. If meta data is also configured on this template, the given metaData
will override any
existing entries under the same key.
This method takes into account that a Unit of Work may be active, using that Unit of Work to ensure
correct publication of the event.payload
- The payload of the event to publishmetaData
- Additional meta data to attach to the eventCopyright © 2010-2014. All Rights Reserved.