2

I am trying to set camel Header value using below Expression

 .setHeader("amqName").simple("${amqAddressMap.get(header.userTypeID)}", String.class)

where amqAddressMap is an array list and passing header value as argument but it shows invalid expression error

is there any way to execute the code without using using processor class

5
  • 1
    Hi! I think you need to have ${amqAddressMap.get(${header.userTypeID})} Commented Jul 9, 2019 at 16:39
  • @Screwtape not working ... Commented Jul 9, 2019 at 18:02
  • 2
    @Screwtape is correct. Also how is amqAddressMap declared? My blind guess is it is your local java variable and you cannot do that, you can only access objects stored in Exchange. Use setProperty("amqAddressMap", constant(amqAddressMap)) and then you can refer it with ${exchangeProperty.amqAddressMap.get(${header.userTypeID})}. And I am pretty sure that the exception message tells a bit more, than "invalid expression error" Commented Jul 9, 2019 at 21:42
  • @Screwtape Setting property fixed the issue. Thanks. Can you make it as an answer. Commented Jul 10, 2019 at 10:35
  • @Bedla - I think this is yours... if you want it... Commented Jul 10, 2019 at 17:54

1 Answer 1

1

To access ArrayList inside exchange we need to set it as a property

setProperty("amqAddressMap", constant(amqAddressMap))

So that we can access it using EL like

${exchangeProperty.amqAddressMap.get(${header.userTypeID})}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.