public interface EventEmitter
Use an instance of the MessageCreator
interface to create Camel Message objects.
Usage examples:
// Example 1: Emitting events as Java objects using XML Binding. Map<String, Object> headers = MessageCreator.createHeadersMap(); headers.put(Note: Some Camel components, such as the JMS component, require additional libraries and configuration prior to using them. In the example above the jms123 requires EDA landscape component definition. This component ID must be previously defined by the administrator which uniquely identifies the JMS server that provides the specified topic. In this case the smtp component does not require additional configuration.EventTypeXSDConstants.STANDARD_HEADER_TYPE
, "{http://namespaces.softwareag.com/EDA/WebM/Sample/InventoryMgmt/1.0}PartInventoryLow"); headers.put("Part$ItemID", "itemID"); headers.put("Part$ItemName", "itemName"); headers.put("InventoryLevel", "2"); PartInventoryLowType bodyAsPOJO = new PartInventoryLowType(); // A valid Java object which contains annotations for XML Binding. MessageCreator msgCreator = ...; // Instantiate or look up an instance of the MessageCreator interface. Message msg = msgCreator.createMessage(bodyAsPOJO, headers); EventEmitter emitter = ...; // Instantiate or look up an instance of the EventEmitter interface. emitter.emit(msg); // Example 2: Emitting events as XML strings. Map<String, Object> headers = MessageCreator.createHeadersMap(); headers.put(EventTypeXSDConstants.STANDARD_HEADER_TYPE
, "{http://namespaces.softwareag.com/EDA/WebM/Sample/InventoryMgmt/1.0}PartInventoryLow"); headers.put("Part$ItemID", "itemID"); headers.put("Part$ItemName", "itemName"); headers.put("InventoryLevel", "2"); String bodyAsXMLString = "<PartInventoryLow xmlns="http://namespaces.softwareag.com/EDA/WebM/Sample/InventoryMgmt/1.0"> <Part> <ItemID>itemID</ItemID> <ItemName>itemName</ItemName> <Model>model</Model> <Color>color</Color> <Shape>shape</Shape> </Part> <InventoryLevel>2</InventoryLevel> <DesiredInventoryLevel>1</DesiredInventoryLevel> </PartInventoryLow>"; MessageCreator msgCreator = ...; // Instantiate or look up an instance of the MessageCreator interface. Message msg = msgCreator.createMessage(bodyAsXMLString, headers); EventEmitter emitter = ...; // Instantiate or look up an instance of the EventEmitter interface. emitter.emit(msg); // Example 3: Emitting events to specific endpoints. String bodyAsXMLString = "... some valid event body as XML string ..."; Map<String, Object> headers = MessageCreator.createHeadersMap(); headers.put("...", "..."); // Put as many headers as you need. This should contain all required headers and filterable properties. ... MessageCreator msgCreator = ...; // Instantiate or look up an instance of the MessageCreator interface. Message msg = msgCreator.createMessage(bodyAsXMLString, headers); String[] endpointUris = { "jms123:topic:topicABC", "smtp://smtp?to=joe.bob@softwareag.com&subject=Inventory shortage alert" }; EventEmitter emitter = ...; // Instantiate or look up an instance of the EventEmitter interface. emitter.emit(message, endpointUris); // Component "jms123" must be configured by the administrator prior to using it.
MessageCreator} - Could be used for creating message objects.
,
EventTypeXSDConstants} - Contains constants that should be used for populating message headers maps.
,
EventTypeXSDConstants#buildCustomHeaderKey(String)} - Used for building customer header map keys.
Modifier and Type | Method and Description |
---|---|
void |
emit(org.apache.camel.Message message)
Emits a Camel message containing an EDA event.
|
void |
emit(org.apache.camel.Message message,
java.lang.String... endpoints)
Emits a Camel message containing an EDA event.
|
java.lang.String |
getCurrentPubSubToEndpointURI(com.softwareag.eda.store.api.EDAEventTypeID eventTypeID)
Returns the endpoint URI of publish-subscribe type to which the eventTypeID is routed.
|
void emit(org.apache.camel.Message message) throws NervException
message
- - The Camel message containing body and headers. It cannot be null.NervException
- Thrown if the specified message is null, one or more required headers are missing,
or some other unpredicted runtime error occurs.void emit(org.apache.camel.Message message, java.lang.String... endpoints) throws NervException
message
- - The Camel message containing body and headers. It cannot be null.endpoints
- - One or more Camel endpoints this event is going to be send to. For more information about
Camel components, endpoints and endpoint URIs take a look at Apache Camel's documentation and JavaDoc.NervException
- Thrown if the specified message is null, one or more required headers are missing,
or some other unpredicted runtime error occurs.java.lang.String getCurrentPubSubToEndpointURI(com.softwareag.eda.store.api.EDAEventTypeID eventTypeID) throws NervException
eventTypeID
- The event type ID for which we get an endpoint URINervException