The sql component might have a flaw there if it clears the headers.
You can try to store it as a property on the Exchange directly and see if its kept.
Feel free to create a bug report, about the clearning header at:
there is a link to JIRA on the page above.
I will test setProperty....
I tested the setProperty() method and it works.
But, I have another question...
How do I use the choice syntax with a property ?
I have tried 2 syntaxes and they failed...
So, only passing the data of a property to Header works..
Is there a way to do it with the property() method of DSL ?
Yeah the Java DSL and the compiler can get a bit spooked when you have some combinations.
When you get to a bad point you kind on have java.lang.Object and its standard methods such as equal.
That is why
Does not work as it uses Object equals and not how its intentded.
We have currently a discussion on the camel dev about use of header/properties. We tend to agree that properties has kinda been negleted a bit and is not promoted enough in the documentation and samples.
Properties should be used for storing key/values that should preserve for the entire lifetime of the Exchange.
That said the Java DSL should of course offer good builder method for using .properties as well.
So what is missing is a better property expression directly in the DSL.
You can probably (I have laptop at the couch in front of the TV so I cant do much coding)
import the class ExpressionBuilder (or use static import of the method below)
And use ExpressionBuilder.propertyExpression("variable") in the DSL
I will check up on this tomorrow so we can have first class support for properties out-of-the-box in the Java and Spring DSL.