You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by javag <ze...@gmail.com> on 2013/10/21 00:20:18 UTC

Camel is not substituting variable expression in route

I have a route in camel.xml like:

<route>
			
			<from uri="jms:myfoo" />
			<doTry>
				<validate><simple>${body[subsc]} regex '[a-z0-9]{8}' </simple>
</validate>
				<choice>
					<when>
						<simple>${body[mykey]} regex '^(T1|T2)$'</simple>
						<choice>
						    <when>
							   <simple>${body[serviceName]} == 'getList'</simple>
							       <to uri="jms:bar.${body[mykey]}.state" />
					             </when>
						</choice>	
				        </when>
					<otherwise>
					<to uri="jms:invalid" />
					<stop />
					</otherwise>
				</choice>
			<doCatch>
				<exception>org.apache.camel.ValidationException</exception>
				<to uri="jms:invalid"/>
			</doCatch>
			</doTry>
				
		</route>
		

When I start activemq and send a message, validation passes and it matches
${body[mykey]} to either T1 or T2  but the message is sent to literally to
bar.${body[mykey]}.state instead of to bar.T1.state or bar.T2.state  i.e. 
it does not substitute the variable body[mykey].

Any idea what is causing this problem? According to camel docs it should
work but it is not working.?

I am using camel 2.10.3 and activemq 5.8.0.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-is-not-substituting-variable-expression-in-route-tp5741934.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel is not substituting variable expression in route

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See this FAQ
http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html

On Mon, Oct 21, 2013 at 12:20 AM, javag <ze...@gmail.com> wrote:
> I have a route in camel.xml like:
>
> <route>
>
>                         <from uri="jms:myfoo" />
>                         <doTry>
>                                 <validate><simple>${body[subsc]} regex '[a-z0-9]{8}' </simple>
> </validate>
>                                 <choice>
>                                         <when>
>                                                 <simple>${body[mykey]} regex '^(T1|T2)$'</simple>
>                                                 <choice>
>                                                     <when>
>                                                            <simple>${body[serviceName]} == 'getList'</simple>
>                                                                <to uri="jms:bar.${body[mykey]}.state" />
>                                                      </when>
>                                                 </choice>
>                                         </when>
>                                         <otherwise>
>                                         <to uri="jms:invalid" />
>                                         <stop />
>                                         </otherwise>
>                                 </choice>
>                         <doCatch>
>                                 <exception>org.apache.camel.ValidationException</exception>
>                                 <to uri="jms:invalid"/>
>                         </doCatch>
>                         </doTry>
>
>                 </route>
>
>
> When I start activemq and send a message, validation passes and it matches
> ${body[mykey]} to either T1 or T2  but the message is sent to literally to
> bar.${body[mykey]}.state instead of to bar.T1.state or bar.T2.state  i.e.
> it does not substitute the variable body[mykey].
>
> Any idea what is causing this problem? According to camel docs it should
> work but it is not working.?
>
> I am using camel 2.10.3 and activemq 5.8.0.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-is-not-substituting-variable-expression-in-route-tp5741934.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen