0

Im trying to set activemq queue name from header value but its not happening below is my Spring DSL

<setHeader headerName="x-so-queue-name" id="_setHeader1">
   <xpath resultType="java.lang.String">/Message/@IntObjectName</xpath>
</setHeader>
<log id="_log1" message="x-so-queue-name::: ${header.x-so-queue-name}"/>
<to id="_to1" uri="activemq:queue:${header.x-so-queue-name}"/>

LOGS 16:03:57,601 | INFO | _route1 | x-so-queue-name::: IDC_SO_Refill_IO

header value is printing in the logs but queue name is set to "${header.x-so-queue-name}" why its not retrieving the the value for header, am i doing some thing wrong

enter image description here

herman shafiq
  • 499
  • 2
  • 8
  • 26
  • See also the FAQ about dynamic to: http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html. But the best solution is what Matt says below to use the CamelJmsDestinationName as a dynamic queue name with minimal overhead in Camel. – Claus Ibsen Jul 05 '17 at 18:16

1 Answers1

3
  1. Replace the 'x-so-queue-name' header name with the header named 'CamelJmsDestinationName'

  2. Then in the uri, remove the ${header.x-so-queue-name}.. you can put whatever queue name you want, since the ActiveMQ component will look at the header to determine the destination name. I generally use the below, as a reminder that I'm using dynamic queue naming in the route:

Reference: Camel JMS Component (search for CamelJmsDestinationName)

Matt Pavlovich
  • 4,087
  • 1
  • 9
  • 17