camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Carman <ja...@carmanconsulting.com>
Subject Re: Content Based Routing with Camel
Date Tue, 10 Dec 2013 01:02:12 GMT
He would need to use a Predicate for CBR.  Either way, it'd be easy to
do, as you pointed out, since it's just a library. :)

Or, if the destination can be "calculated" based on something in your
JSON (using an expression), you could do something like this:

from(...).deserialize(...).recipientList(simple("some simple expression");

On Mon, Dec 9, 2013 at 7:43 PM, Christian Posta
<christian.posta@gmail.com> wrote:
> If you're set on JsonPath, you can do so in a POJO or processor as
> it's just a library:
>
> http://code.google.com/p/json-path/
>
> On Mon, Dec 9, 2013 at 1:57 PM, Henryk Konsek <hekonsek@gmail.com> wrote:
>> Hi guys,
>>
>>> Perhaps you can deserialize the object(s) first before doing CBR
>>> (using a simple expression)?
>>
>> This is very good suggestion, James. To make it a little more concrete:
>>
>> from(...).
>>   unmarshal().json(JsonLibrary.Gson, Map.class).
>>     choice().
>>       when().simple("${body[invoices][latest][netValue] > 1000}").to(...).
>>       otherwise().to(...).
>>    endChoice();
>>
>> You can use JSON data format [1] (I use Google GSON in the example) to
>> deserialize incoming message. In the example below I deserialize it to
>> Map, because I don't know the type of the message (to make things
>> little more tricky). And yeah, GSON handles nested Maps pretty well.
>> To analyse content of the nested maps structure you might use Simple
>> [2] expression (as James suggested) because it supports nested map
>> keys notation (as in the example). And nested maps keys is something
>> similar to JsonPath you wanted to have :) .
>>
>> Cheers.
>>
>> [1] http://camel.apache.org/json
>> [2] http://camel.apache.org/simple
>>
>> --
>> Henryk Konsek
>> http://henryk-konsek.blogspot.com
>
>
>
> --
> Christian Posta
> http://www.christianposta.com/blog
> twitter: @christianposta

Mime
View raw message