You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by sprabu <sa...@gmail.com> on 2012/12/18 17:09:10 UTC

How do i read the xml element values from the xml payload and have to pass those values to sql query.

Hi,
I'm getting messages from route and want to insert xml payload values in
sql. 
<from uri=queue:com.test.Queue1>
<to uri="sql:insert into MY_TABLE
values(${in.header.MessageId},//Element1,//Element2)" />
....

Also i want to pass the jms message id to the sql query. 
How do i read the xml element values from the xml payload and have to pass
those values to sql query?
This should be done in the spring xml dsl.

Thanks in advance.



--
View this message in context: http://camel.465427.n5.nabble.com/How-do-i-read-the-xml-element-values-from-the-xml-payload-and-have-to-pass-those-values-to-sql-query-tp5724291.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How do i read the xml element values from the xml payload and have to pass those values to sql query.

Posted by Henrique Viecili <he...@myreks.com>.
According to the camel-sql documentation, you must set the message body
with a java.util.Iterator containing the parameters used in your query (in
the correct order).
*
att.
Henrique Viecili*




On Wed, Dec 19, 2012 at 11:05 AM, Willem jiang <wi...@gmail.com>wrote:

> I don't think camel-sql component support to get the value form message
> header.
> You may consider to use recipientList[1] to send the message to the
> endpoint which uri is generated dynamically.
>
> [1]http://camel.apache.org/recipient-list.html
>
> --
> Willem Jiang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
> (English)
>           http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
>
>
>
>
> On Wednesday, December 19, 2012 at 8:31 PM, sprabu wrote:
>
> > Hi,
> > I tried in 'n' number of way. At last i tried in the following way. Even
> now
> > i'm getting error.
> >
> > <to uri="sql:insert into TASK_TABLE
> >
> values(#header.msg_seq_no#,'TEST_CAMEL','112233','W-001','TEST','','','','')"
> > />
> >
> > Can any one please help me to come out of it?
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/How-do-i-read-the-xml-element-values-from-the-xml-payload-and-have-to-pass-those-values-to-sql-query-tp5724291p5724362.html
> > Sent from the Camel - Users mailing list archive at Nabble.com (
> http://Nabble.com).
>
>
>
>

Re: How do i read the xml element values from the xml payload and have to pass those values to sql query.

Posted by Willem jiang <wi...@gmail.com>.
I don't think camel-sql component support to get the value form message header.
You may consider to use recipientList[1] to send the message to the endpoint which uri is generated dynamically.

[1]http://camel.apache.org/recipient-list.html  

--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Wednesday, December 19, 2012 at 8:31 PM, sprabu wrote:

> Hi,
> I tried in 'n' number of way. At last i tried in the following way. Even now
> i'm getting error.
>  
> <to uri="sql:insert into TASK_TABLE
> values(#header.msg_seq_no#,'TEST_CAMEL','112233','W-001','TEST','','','','')"
> />
>  
> Can any one please help me to come out of it?
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-do-i-read-the-xml-element-values-from-the-xml-payload-and-have-to-pass-those-values-to-sql-query-tp5724291p5724362.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: How do i read the xml element values from the xml payload and have to pass those values to sql query.

Posted by sprabu <sa...@gmail.com>.
Hi,
I tried in 'n' number of way. At last i tried in the following way. Even now
i'm getting error.

<to uri="sql:insert into TASK_TABLE
values(#header.msg_seq_no#,'TEST_CAMEL','112233','W-001','TEST','','','','')"
/>

Can any one please help me to come out of it?



--
View this message in context: http://camel.465427.n5.nabble.com/How-do-i-read-the-xml-element-values-from-the-xml-payload-and-have-to-pass-those-values-to-sql-query-tp5724291p5724362.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How do i read the xml element values from the xml payload and have to pass those values to sql query.

Posted by sprabu <sa...@gmail.com>.
Hi
I have in the follwoing way. But its showing me bad sql grammer exception.
Can you help me to come out of this.

<route>
<from uri="queue:com.TaskQueue1" />
<setHeader headerName="msg_no">
<xpath>//MESSAGE_NUMBER</xpath>
</setHeader>
<to uri="sql:insert into TASK_TABLE
values(${header.msg_seq_no},'TEST_CAMEL','112233','W-001','TEST','','','','')"
/>
.......	
How do i get the value and set it in sql?

Thanks in advance!
				



--
View this message in context: http://camel.465427.n5.nabble.com/How-do-i-read-the-xml-element-values-from-the-xml-payload-and-have-to-pass-those-values-to-sql-query-tp5724291p5724353.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How do i read the xml element values from the xml payload and have to pass those values to sql query.

Posted by Henrique Viecili <he...@myreks.com>.
You could use setHeader with xpath, like:

<camel:setHeader headerName="element1">
   <camel:xpath>//Element1</camel:xpath>
</camel:setHeader>

and then, use these headers in you sql: statement.

to read the message id you can do as described in [1] with ${id}

[1] http://camel.apache.org/simple.html - Simple Expression Language

att.
*Henrique Viecili*


On Tue, Dec 18, 2012 at 2:09 PM, sprabu <sa...@gmail.com> wrote:

> Hi,
> I'm getting messages from route and want to insert xml payload values in
> sql.
> <from uri=queue:com.test.Queue1>
> <to uri="sql:insert into MY_TABLE
> values(${in.header.MessageId},//Element1,//Element2)" />
> ....
>
> Also i want to pass the jms message id to the sql query.
> How do i read the xml element values from the xml payload and have to pass
> those values to sql query?
> This should be done in the spring xml dsl.
>
> Thanks in advance.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-do-i-read-the-xml-element-values-from-the-xml-payload-and-have-to-pass-those-values-to-sql-query-tp5724291.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>