You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by gmh <go...@gmail.com> on 2014/11/20 22:21:41 UTC

question about using splitter(?) and jsonpath expression

All,
I am trying to come up with a processing pattern for a business case.
Assume we have something like this form a queue (ActiveMQ/Rabbbitmq) does
not matter 
Below is the json
{
   "name":"xyz"
   "address": "123 Somewhere, USA"
   "ssn": "1234"
}
For each name/value pair I want to make a call to the database with the
value that is provided.
so essentially it will be something like this: 
   Get value from name, insert value "xyz"  into db with the collection
called name
   Get value for address, insert value "123..." into mongodb with the
collection called 

from (activemq:queue name)
.to (mongodb:insert ($.name[0])&collection"name")

How do I create different routes/queues via jsonpath expression to make it
happen? assuming we will always have the same name:value pair and therefore
the same collections.

Gordon




--
View this message in context: http://camel.465427.n5.nabble.com/question-about-using-splitter-and-jsonpath-expression-tp5759384.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: question about using splitter(?) and jsonpath expression

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Maybe use camel-jackson to unmarshal the json to a java.util.Map (it
does that by default)
http://camel.apache.org/json.html

And then you can use recipient list to call the 3 mongodb endpoints.
http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html

And from the java.util.Map object you can use the simple langue or
groovy etc to access the entry you want

simple("mongodb:${body['name']}&collection=name")


On Thu, Nov 20, 2014 at 10:21 PM, gmh <go...@gmail.com> wrote:
> All,
> I am trying to come up with a processing pattern for a business case.
> Assume we have something like this form a queue (ActiveMQ/Rabbbitmq) does
> not matter
> Below is the json
> {
>    "name":"xyz"
>    "address": "123 Somewhere, USA"
>    "ssn": "1234"
> }
> For each name/value pair I want to make a call to the database with the
> value that is provided.
> so essentially it will be something like this:
>    Get value from name, insert value "xyz"  into db with the collection
> called name
>    Get value for address, insert value "123..." into mongodb with the
> collection called
>
> from (activemq:queue name)
> .to (mongodb:insert ($.name[0])&collection"name")
>
> How do I create different routes/queues via jsonpath expression to make it
> happen? assuming we will always have the same name:value pair and therefore
> the same collections.
>
> Gordon
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/question-about-using-splitter-and-jsonpath-expression-tp5759384.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/