Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

dynamically define cJMS destination queue

Hi
Is it possible to define the destination queue of the cJMS component dynamically?
I tried to define the destination by a context variable but if I change the value of the context variable within the route, the new value is not known in the cJMS component.
Any ideas?
thanks, laci

Labels (2)
20 Replies
Anonymous
Not applicable

Hi Laci,
You can manipulate what queue cJMS will use at runtime by changing a header on the Camel Exchange.
Please see:
http://camel.apache.org/jms.html
Heading: Reuse endpoint and send to different destinations computed at runtime
You can use the cSetHeader component (or your custom processor) to set the CamelJmsDestinationName header to the desired queue name.
Hope that helps!
-Ben
_AnonymousUser
Specialist III
Specialist III
Author

Hi Ben
Thanks a lot. A simple and working way to do it!
Best,
Laci
_AnonymousUser
Specialist III
Specialist III
Author

hi ,
i want to set Content-Type value dynamically from database in cHttp ?
Can anyone tell me how to do this?
Anonymous
Not applicable

Hi Suresh,
Please post your question as a new thread.  When you do, try and be more descriptive about your use case.
Anonymous
Not applicable

Hi Suresh,
This example uses XPath to pull a value from an XML message and use it as the queue name in the following cJMS component.  The appearance is a little different from 5.x because it's 6.0.
Hope this helps.
0683p000009MAGn.png
vharcq
Contributor III
Contributor III

Hi guys
I had similar question recently in a Message Dispatcher need.  
Here was my approach
I choosed a combination of 

cProcessor (or anything else) that sets a Header variable
"MYQUEUE"

(depending of my logic)
cRecipientList with a Simple expression 
"cMQConnectionFactory1:queue:"+"${in.header.MYQUEUE}"


The trick is the URI that uses the JMS Connection Factory
Vincent
Loko
Creator II
Creator II

Yes, just have to change the "CamelJmsDestinationName" header and that's all

 

One thing to understand with contexts is they behave completly differet in routes/camel than in jobs. They are read at route startup but if you change their values they never will be taken in account. So they are only constant values. Headers and properties are the main stuff for dynamic variables.

 

Loko

davidferguson
Contributor III
Contributor III

Hey Loko,

 

that's not exactly true! Have a look hereto check out how to change your contexts with the help of external config files - it's pretty useful!

Thanks for the tip about the JMS Header!

 

David.

Loko
Creator II
Creator II

Hi David.
I know that .cfg file option, but what I said stays 100% true ! Once the value has been initialized, in the route itself or overriden by the cfgFile, it will never change. You could manually change its value in a cProcessor for instance, but the change would be lost for the nexr steps of your route.
davidferguson
Contributor III
Contributor III

@Loko,

 

maybe I'm not understanding you correctly...

 

Here's an example of what I mean:

0683p000009LzhN.pngSimple REST Service set-up

0683p000009LzQ7.pngContents of cSetBody with context variable usage

0683p000009LzBg.pngContext variable initialisation

0683p000009LzhW.pngGET REST call with browser

0683p000009Lzhb.pngGetting ID

0683p000009Lzaw.pngUpdating config for the already deployed service

0683p000009Lzhg.pngSecond GET REST call to service after update

Can you show me an example of what you mean? I'm still quite new to Routes in Talend ESB and still trying to get my head around them, so it's quite possible that I'm missing something. In any case, if you have anything to teach me about Routes, I'll gladly take the advice!

 

Thanks,

 

David.