Using EPL to send and receive JMS messages
The EPL code necessary for using correlator-integrated messaging for JMS is minimal.
Initialization - Your application needs to notify the correlator that the application has been injected and is ready to process events from the JMS broker.
1. Apama recommends that after all an application's EPL has been injected, the application should send an application-defined 'start' event using a .evt file. Using an event is clearer and more reliable than enabling JMS message receiving using monitor onload() actions because it is easier to guarantee that all EPL has definitely been injected and is in a good state before the event is sent and JMS message receiving commences.
2. Any monitors that need to use the correlator-integrated messaging for JMS event API will have a variable (typically a monitor-global field) holding a JMS event object.
3. The monitor that handles the application-defined start event (from step 1), should use this JMS event object to notify correlator-integrated messaging for JMS that the application is initialized and ready to receive messages, for example:
on com.mycompany.myapp.Start() {
jms.onApplicationInitialized();
// Any other post-injection startup logic goes here too.
}
Receiving events - After configuring a JMS receiver, add EPL listeners for the events specified in the mapping configuration.
Sending events - Send the Apama event associated with the JMS message in the
Sender Mapping Configuration by using the following syntax.
send event_name to "jms:senderId";
Note, senderId is typically "connectionId-default-sender" unless explicitly configured with a different name. For example to send an event to the default sender on a connection called "MyConnection", use the following:
send MyEvent to "jms:MyConnection-default-sender";
For more information on specifying the message's JMS destination, see
Configuring sender event mappings.