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
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

View solution in original post


All Replies
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

View solution in original post

Highlighted
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!!

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog