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,
You can use context value in cJMS destination queue.
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.

Please give us the screenshots of your current contexts setting so that we can address your issue.
Best regards
Sabrina
_AnonymousUser
Specialist III
Specialist III
Author

Hi Sabrina
Yes, I know that I can use a context Variable. What I tried is to set the value of a context variable in a cProcessor Component
context.put("destinationEvita", "new.queue");
the cProcessor component leads to the cJMS component which uses context.destinationEvita as Destination.
But when you look at the source code, you will see that the Destination which the cJMS component will use is set in a initialization phase when the route starts. So setting the value of that context variable at runtime has no effect.
Any other way to set the Destination field of the cJMS component dynamically?
Thanks,
Laci
Anonymous
Not applicable

Hi,
Why don't you set the context value in "Contexts" view? It seems what you put value to a global variable?
Best regards
Sabrina
0683p000009MAIS.jpg
_AnonymousUser
Specialist III
Specialist III
Author

Hi Sabrina
sorry, you don't seem to understand what I mean.
I want to set the queue dynamically in the cJMS component. That means, that I want to be able to change the queue during the process of my route.
For example: Say, I have a header variable QueueName="queue1"
then I want to send my message to queue1.
If the value of my header variable is QueueName="queue2"
then I want to send my message to queue2
That's why I tried to change the value of the context variable.

How can I upload a screenshot here? I can't find a button for that.
Best, Laci
Anonymous
Not applicable

Hi,
You should register and log in as a Community member first, then you'll get a Image upload box that allows to upload screen captures and images up to 200KB.(20 images per post, each image must be less then 1024x768 pixels and 200 KB)
For registered users, please clicking on "post reply" (not through the quick post").
Best regards
Sabrina
Anonymous
Not applicable

If you are familiar with Camel, you can use Camel Properties.
http://camel.apache.org/properties.html
_AnonymousUser
Specialist III
Specialist III
Author

Thanks camsellem, that helped a bit further.
In a cProcessor component I have the following code:
org.apache.camel.component.properties.PropertiesComponent pc = new org.apache.camel.component.properties.PropertiesComponent();
pc.setLocation("file:/home/talend/msp.properties");
org.apache.camel.CamelContext camelContext = getCamelContextMap().get("TestCntx-ctx");
camelContext.addComponent("properties", pc);
(TestCntx-ctx is the name of my route)
the cProcessor component leads to a cMessagingEndpoint with the URI:
"{{destination.queue}}"
which is defined in the file /home/talend/msp.properties as follows:
destination.queue=myQueue
When I run it in Talend Studio I get the error:
Failed to create route cJMS_1 at: >>> To <<< in route: Route] -> [pr... because of PropertiesComponent with name properties must be defined in CamelContext to support property placeholders.

I suspect that it doesn't work because the PropertiesComponent object is not registered correctly. But how do I do it?
Thanks for your help,
Laci
_AnonymousUser
Specialist III
Specialist III
Author

ok, I found the solution.
I have to define the PropertiesComponent in a cConfig component like this:
org.apache.camel.component.properties.PropertiesComponent pc = new org.apache.camel.component.properties.PropertiesComponent();
pc.setLocation("file:/home/talend/msp.properties");
camelContext.addComponent("properties", pc);

And then I can use a cJMS component with destination:
"{{destination.queue}}"
where
destination.queue=queue.name
is defined in /home/talend/msp.properties
_AnonymousUser
Specialist III
Specialist III
Author

... but how can I change the value of a Camel Property at runtime?