dimanche 20 avril 2014

Java - Camel...l'utilisation de xpath pour analyser le xml dans le corps du message - Stack Overflow


I have a simple flow that reads from an activemq1 and parses an id from the message and sends the id across to another activemq2.


Here is an example of message that gets written to activemq1:


<Customer>
<Order>
<id>123</id>
</Order>
<Customer>

I need to parse out the id from the above message body and send the below message to activemq2:


"Order with id{123} has been queued" 

This is the flow that I cameup with, but it writes the complete request xml to the queue, but not the message that I am looking for:


<from uri="jms:queue:Q.activemq1"/>
<setBody>
<xpath>"/Customer/Order/id/@value/text()"</xpath>
</setBody>
<to uri="jms:queue:Q.activemq2"/>

Anything wrong in the above or any corrections




Use


<route>
<from uri="jms:queue:Q.activemq1" />
<setBody>
<xpath>/Customer/Order/id/text()</xpath>
</setBody>
<setBody>
<simple>Order with ${body} has been queued</simple>
</setBody>
<log message="${body}"/>
</route>

This prints


Order with 123 has been queued


I have a simple flow that reads from an activemq1 and parses an id from the message and sends the id across to another activemq2.


Here is an example of message that gets written to activemq1:


<Customer>
<Order>
<id>123</id>
</Order>
<Customer>

I need to parse out the id from the above message body and send the below message to activemq2:


"Order with id{123} has been queued" 

This is the flow that I cameup with, but it writes the complete request xml to the queue, but not the message that I am looking for:


<from uri="jms:queue:Q.activemq1"/>
<setBody>
<xpath>"/Customer/Order/id/@value/text()"</xpath>
</setBody>
<to uri="jms:queue:Q.activemq2"/>

Anything wrong in the above or any corrections



Use


<route>
<from uri="jms:queue:Q.activemq1" />
<setBody>
<xpath>/Customer/Order/id/text()</xpath>
</setBody>
<setBody>
<simple>Order with ${body} has been queued</simple>
</setBody>
<log message="${body}"/>
</route>

This prints


Order with 123 has been queued

0 commentaires:

Enregistrer un commentaire