-
1. Re: Sql component is reseting my Headers
davsclaus Jan 23, 2009 12:32 AM (in response to jklemm)Hi
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.
exchange.setProperty("foo", "bar");
Feel free to create a bug report, about the clearning header at:
http://camel.apache.org/support.html
there is a link to JIRA on the page above.
-
2. Re: Sql component is reseting my Headers
davsclaus Jan 23, 2009 1:29 AM (in response to davsclaus)I created the bug reported and fixed it in the next Camel
-
3. Re: Sql component is reseting my Headers
jklemm Jan 23, 2009 1:30 PM (in response to davsclaus)Hi,
I will test setProperty....
Thanks again.
-
4. Re: Sql component is reseting my Headers
jklemm Jan 26, 2009 1:05 PM (in response to jklemm)Hi davsclaus,
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...
.choice()
.when().property("variable").equals(1)
.choice()
.when(property("variable").equals(1))
So, only passing the data of a property to Header works..
.setHeader("variable", getProperty("var"));
.choice()
.when(header("variable").isEqualTo(1))
Is there a way to do it with the property() method of DSL ?
Thanks,
-
5. Re: Sql component is reseting my Headers
davsclaus Jan 26, 2009 1:59 PM (in response to jklemm)Hi
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
choice()
.when().property("variable").equals(1)
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
.choice()
.when(ExpressionBuilder.propertyExpression("variable")).isEqualTo(1)
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.
-
6. Re: Sql component is reseting my Headers
davsclaus Jan 30, 2009 2:58 AM (in response to jklemm)I have created a ticket at Apache for this, to add some samples and make sure we have first class support for properties in all the DSL's