You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Alexander Kaiser <al...@gmail.com> on 2012/06/06 23:18:42 UTC

adding headers to a message based on a databse query

Hi,

I wonder whether it is possible to add message headers to a message based
on the results of a jdbc query without writing a custom processor.

E.g. I have a message with a header 'userid'. And I have a database table
users which contains user's properties.
Now I want to use the value of the userid header to query the database
table users and add the columns received from the database as headers to
the message.
Further down the route I want to use the headers/properties recieved from
the database to make routing decisions.

-- 
Alexander

Re: adding headers to a message based on a databse query

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 7, 2012 at 8:26 AM, Alexander Kaiser
<al...@gmail.com> wrote:
> Hi Claus,
>
> thanks for your answer!
>
> Isn't it so that setHeader only sets one (named) header?
> So to set multiple headers from a single query I do have to use content
> enricher + custom aggregation strategy?
>

Yes setHeader sets only a single header.


> Alexander
>
> 2012/6/7 Claus Ibsen <cl...@gmail.com>
>
>> The setHeader DSL uses an expression, so if you can write an
>> expression that gets the SQL result then that can be done without a
>> processor.
>> You can also use the content enricher, but then you would need to
>> write a custom aggregation strategy to enrich the headers.
>>
>>
>> On Wed, Jun 6, 2012 at 11:18 PM, Alexander Kaiser
>> <al...@gmail.com> wrote:
>> > Hi,
>> >
>> > I wonder whether it is possible to add message headers to a message based
>> > on the results of a jdbc query without writing a custom processor.
>> >
>> > E.g. I have a message with a header 'userid'. And I have a database table
>> > users which contains user's properties.
>> > Now I want to use the value of the userid header to query the database
>> > table users and add the columns received from the database as headers to
>> > the message.
>> > Further down the route I want to use the headers/properties recieved from
>> > the database to make routing decisions.
>> >
>> > --
>> > Alexander
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>
>
>
>
> --
> Alexander



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: adding headers to a message based on a databse query

Posted by Alexander Kaiser <al...@gmail.com>.
Hi Claus,

thanks for your answer!

Isn't it so that setHeader only sets one (named) header?
So to set multiple headers from a single query I do have to use content
enricher + custom aggregation strategy?

Alexander

2012/6/7 Claus Ibsen <cl...@gmail.com>

> The setHeader DSL uses an expression, so if you can write an
> expression that gets the SQL result then that can be done without a
> processor.
> You can also use the content enricher, but then you would need to
> write a custom aggregation strategy to enrich the headers.
>
>
> On Wed, Jun 6, 2012 at 11:18 PM, Alexander Kaiser
> <al...@gmail.com> wrote:
> > Hi,
> >
> > I wonder whether it is possible to add message headers to a message based
> > on the results of a jdbc query without writing a custom processor.
> >
> > E.g. I have a message with a header 'userid'. And I have a database table
> > users which contains user's properties.
> > Now I want to use the value of the userid header to query the database
> > table users and add the columns received from the database as headers to
> > the message.
> > Further down the route I want to use the headers/properties recieved from
> > the database to make routing decisions.
> >
> > --
> > Alexander
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>



-- 
Alexander

Re: adding headers to a message based on a databse query

Posted by Claus Ibsen <cl...@gmail.com>.
The setHeader DSL uses an expression, so if you can write an
expression that gets the SQL result then that can be done without a
processor.
You can also use the content enricher, but then you would need to
write a custom aggregation strategy to enrich the headers.


On Wed, Jun 6, 2012 at 11:18 PM, Alexander Kaiser
<al...@gmail.com> wrote:
> Hi,
>
> I wonder whether it is possible to add message headers to a message based
> on the results of a jdbc query without writing a custom processor.
>
> E.g. I have a message with a header 'userid'. And I have a database table
> users which contains user's properties.
> Now I want to use the value of the userid header to query the database
> table users and add the columns received from the database as headers to
> the message.
> Further down the route I want to use the headers/properties recieved from
> the database to make routing decisions.
>
> --
> Alexander



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen