Hi everybody,
I need some help with Apama and JMS Correlator-Integrated Adapter.
I have published some XML messages on a queue on Universal Messaging 9.8.
I’m using Apama 5.3.0.0 and I would like to dequeue these messages and to transform it in events that Apama can compute.
For this I have created a new Apama project selecting the required bundle instances like JMS Correlator-integrated Adapter.
Than I have configured a new connection to Universal Messaging from the instance of the JMS Correlator-Integrated Adapter and I have specified the classpath for this connection by selecting the installation directory of Universal Messaging.
Later, I configured the connection properties as follows:
Connection Factory JNDI Lookup Name → same as the one that I have created before on Universal Messaging
Provider URL → nsp://127.0.0.1:9000
Finally, I added a new static receiver by specifying the name of the Universal Messaging queue that I want to connect to.
In the Event Mappings tab, I configured a Receiver Mapping Configuration: I added an event that is among the events defined in the folder eventdefinition in the file extension .mon.
I used the XML template configuration for the Mapping Definition by right click on JMS Body, then ‘Treat as XML’ , and selecting an xml template file which has the same schema of the xml messages on the UM queue.
In the End, I map the xml message from the queue with the Apama event.
When I run the correlator instance, I enabled the “JMS support” in the “run configuration” menu.
The problem is that I am not able to dequeue xml messages to be mapped as Apama events.
Using the UM Enterprise Manager I verified that there are some connections between Apama and UM.
I also verified that the JUEL expression on the receiver mapping configuration is valid since it is based on a JMSProperty that I correctly defined.
However my Apama project is not able to dequeue messages and therefore to map them to Apama events in order to be processed by the correlator instance.
How can I solve this issue?
Any help is much appreciated.
Thank you in advance
The clue as to what is going wrong is very likely to be found in the correlator.log file. There will be messages there saying whether it’s connected to JMS, and if so whether it’s successfully created the consumer/receiver for the queue, and whether you called jms.onApplicationInitialized() in your EPL app. There would be errors/warnings if something had gone wrong.
If it’s still not clear to you when you look at the log, please reply with the full log pasted in (as a text attachment).
Thank you for your quick reply.
I haven’t found the correlator.log file: can you please suggest me its location?
Please find below a list of all files contained in the “logs” folder in Apama Work.
I have already taken a look at all the files but I couldn’t figure out any error or warning message.
Sorry for the pastebin links but I couldn’t find a way to post text attachments.
Thank you for the support
I assume you’re starting the correlator from within Apama Studio/Designer? In which case the correlator output by default appears in the Console view at the bottom of the window.
For capturing and sending on to other people the easiest thing is usually to edit the launch configuration (Run Menu | Run Configurations… | then select your the one for your project) and under the Components tab edit default correlator and tick the box “Log to file”. This will then appears in the logs/ directory under your project dir.
Here is the link to the correlator log [url]http://pastebin.com/MccTktdg[/url].
We read through the log file but we weren’t able to identify the source of the problem.
It logs to say it successfully created the connection, but not the consumer. Almost always this is due to forgetting to call JMS.onApplicationInitialized() which is how your application tells the correlator it is ready to start receiving messages.
See the documentation topic Connecting: Apama Applications to External Components > Using Message Services > Using Correlator-Integrated Messaging for JMS > Getting started with simple correlator-integrated messaging for JMS > Using EPL to send and receive JMS messages
Typically (in a non-trivial app with multiple monitors) you would define a Start event and put it into a .evt file whcih gets sent in after all your EPL has been injected to notify the point when you’re ready to start receiving messages, e.g.
com.apama.correlator.jms.JMS jms;
on com.mycompany.myapp.Start() {
jms.onApplicationInitialized();
// Any other post-injection startup logic goes here too.
}
Thank you for your help. I am now able to dequeue messages.
But now I’ve a new problem.
In the Event Mappings tab, I configured a Receiver Mapping Configuration: I added an event that is among the events defined in the folder eventdefinition in the file extension .mon.
I used the XML template configuration for the Mapping Definition by right click on JMS Body, then ‘Treat as XML’ , and selecting an xml template file which is a sample message from the UM queue.
The xml template file has the following structure:
<data>
<ip>196.150.154.129</ip>
<user>jryanrr</user>
<verb>POST</verb>
<resource>/pellentesque.jsp</resource>
<version>HTTP/1.1</version>
<statuscode>500</statuscode>
</data>
In the End, I map the xml message () from the queue with the Apama event defined as follows:
event LogEntry {
string ip;
string user;
string verb;
string resource;
string version;
integer statuscode;
}
but I’ve these WARNING and ERROR:
what am I missing?
It looks like the JMS Body does not contain valid XML.
You can verify if you are receiving the proper XML by logging the received JMS message. You can enable JMS message logging by setting the logJmsMessages and logJmsMessageBodies properties for receivers to true in jms-global-spring.xml file in the Advanced tab of the adapter.
Please post the JMS message logged so I can verify if the JMS body contains valid XML.
How are you publishing the message to JMS? Using Paho MQTT like tool or through any other application?
Looks like you are receiving the JMS message as stream but you are treating it as bytes. Try to treat it as a stream. There is a radio button to choose the type. Select stream there and try to run.
Thank you for the support.
I solved the issue: it was caused by the jms message being treated as bytes instead of a stream.
The messages were enqueued using webMethods IS.
Thank you
Hey guys,
Can you please tell me where is this radio button where you specify that the message is treated as stream not bytes.
Thanks,
Wanis
In the Event Mapping screen of your queue configuration, go to Mappings Definitions and look for ‘JMS Body’. You can right click on it to choose ‘Treat as’ where you will get an option to treat the message as a byte or stream.
ok but the JMS body : bytes message doesn’t have the nodes populated automatically like name and user_id in your example, and when i try to print the object from my monitor it always displays bytes not readable strings.
I usually publish the document as a JMS message from the designer.
Do you have any ideas how to solve this?
Thanks.
I solved the issue by adding computed nodes for each message attribute with xpath and evaluated the expressions using xpath text() method.
this was made in the custom atrributes section in the mapping tab, the sent message was an xml string