How to consume messages selectively using cJMS from ActiveMQ topic in Talend Route

Six Stars

How to consume messages selectively using cJMS from ActiveMQ topic in Talend Route

I'm using Talend route and the cJMS component to push and pull message from the ActiveMQ topic.

I need to retrieve the message on the basis of some property so that message can be differentiated for the multiple consumers of the topic. How and Where can I set this property so that while pulling the message from MQ I can use it?

 

I've tried the URI properties in the "advance settings" of cJMS component but still it is picking all the messages.

 

How can I achieve this? Let me know if I can provide any other information.


Accepted Solutions
Highlighted
Employee

Re: How to consume messages selectively using cJMS from ActiveMQ topic in Talend Route

Hi you need to use JMS selectors for filtering messages.
try using in advanced options
selector = header_FIELDNAME header_FIELDVALUE_using_sql_expresssion
see camel documentation for selector
http://camel.apache.org/jms.html

All Replies
Highlighted
Employee

Re: How to consume messages selectively using cJMS from ActiveMQ topic in Talend Route

Hi you need to use JMS selectors for filtering messages.
try using in advanced options
selector = header_FIELDNAME header_FIELDVALUE_using_sql_expresssion
see camel documentation for selector
http://camel.apache.org/jms.html
Six Stars

Re: How to consume messages selectively using cJMS from ActiveMQ topic in Talend Route

Thanks for your response rchinta_talend.

 

I'm really new to this and as per my understanding I need to add the header first and then use that header as my selector. I tried changing the flow, please check the screenshot.

sub5.JPGHeader Settingsub6.JPGSelector

 

pub_cjms.JPGpublisher cjms

 

I tried understanding the documentation, but i didn't get any source to write the below expression.

 selector = header_FIELDNAME header_FIELDVALUE_using_sql_expresssion.

If it's not too much to ask, an example for the same would work for the me.

 

I'm still confused,

should I add the header and use it as selector in advance properties of consumer JMS?

or should I add the properties in advance options of publisher JMS and same properties in consumer JMS?

or should I not add the header at all?

How can I use the selector to filter?

 

Six Stars

Re: How to consume messages selectively using cJMS from ActiveMQ topic in Talend Route

In my publisher route I used the cSetHeader to add a header with my message ("Header", "MyHeader" ).

In my subscriber route, in the advance properties of cJMS component i added a selector like following

"selector" ,"Header = 'MyHeader'".

Using this I'm able to pick messages selectively from the Topic.

 

Thanks for your help, rchinta_talend!!