jms - Pick specific header messages using activemq,camel selectors from queue -


how consume specific header messages queue. using camel activemq.

routebuilder:

.....     from("activemq:q1").       .setheader("myheader",xpath(...))           .to("activemq:q2") ..... 

and trying consume messages has specific header in class like.

.... consumertemplate consumertemplate = camelcontext.createconsumertemplate(); exchange exchange = consumertemplate.receive("activemq:q2",10000);  string body = exchange.getin().getbody(string.class); string customvalue = exchange.getin().getheader("myheader", string.class); ..... 

how can messages has myheader=123.?

you can use jms message selectors. in camel consumer endpoint can use selector option: http://camel.apache.org/jms

something long lines of

exchange exchange = consumertemplate.receive("activemq:q2?selector=myheader",10000); 

though can't remember if name of header enough or need do

exchange exchange = consumertemplate.receive("activemq:q2?selector=myheader %3d '*'",10000); 

where %3d = encoded.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -