Deploying and Managing Apama Applications > Correlator-Integrated JMS Messaging > Getting started - creating an application with simple JMS messaging > Using EPL to send and receive JMS messages
Using EPL to send and receive JMS messages
The EPL code necessary for using correlator-integrated JMS message 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 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 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 - Once you have configured a JMS receiver, to receive JMS messages, you simply need to add EPL listeners for the events specified in the mapping configuration.
*Sending events - To send JMS messages emit the Apama event associated with the JMS message in the Sender Mapping Configuration using the following syntax.
emit event_name to "jms:senderId";
Note, senderId is typically "connectionId-default-sender" unless explicitly configured with a different name. For example to emit an event to the default sender on a connection called "MyConnection", use the following:
emit MyEvent to "jms:MyConnection-default-sender";
For more information on specifying the message's JMS destination, see Configuring Sender Event Mappings.
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.