You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mattmadhavan <ma...@yahoo.com> on 2014/08/20 23:51:35 UTC

Camel Custom Splitter Question

Hello,
I want to able be able to write a custom  splitter such that: 
1) A message with  collection is broken down into individual
message(exchange)
2) Based on the content of the message add a Message header.
3) Aggregate the split messages using the message header as the strategy.

The only way I see is to use a content enricher/processor to perform step
2). Is there a way to combine step 1) and 2)?

Or if there is any other idea I am all for it.

Can some one point me to the right direction please?

Thanks in advance!
Matt





-----
Thanks
Matt G. Madhavan
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Custom-Splitter-Question-tp5755453.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: AW: Camel Custom Splitter Question

Posted by mattmadhavan <ma...@yahoo.com>.
Hello Jan,
Thank you very much for your reply. But this still does not solve my
problem. The collection of Cancer records loaded from the DB has records
from various cancer sites (Like Colon, Breast, Prostate ). The type of
record is "*CancerRecord*" and the filed *PrimarySite *identifies the Cancer
site.

I am trying to split the records and add a header ("CancerSite="Beast", or
"CancerSite="Colon") etc to the split messages in the exchange.

Then I want to aggregate the records to 500 records of the same CancerSite
and route it to a DroolsCamel component. Please note that there is a
DroolsComponent for each CancerSite.

My question is how and when (and where) I set the message header for
CancerSite?

Also I see xpath expressions for looking into the body but is there any
example where a field in a Java Object can be looked into?

Thanks in advance!

Matt'M




-----
Thanks
Matt G. Madhavan
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Custom-Splitter-Question-tp5755453p5755501.html
Sent from the Camel - Users mailing list archive at Nabble.com.

AW: Camel Custom Splitter Question

Posted by "Jan Matèrne (jhm)" <ap...@materne.de>.
I wouldnt combine these steps (separation of concerns; readability of the
route), especially if #2 is a one liner:

from(...)
   .setHeader("MyMessageHeader", xpath(...)) //1
   .split(body())  // 2
   .to(..whereToProcess..)  
   .aggregate(header("MyMessageHeader")) // 3

#1: Setting the header before splitting them has the advantage that all
split messages should have that common header.
    (please test ;)
#2:
https://camel.apache.org/splitter.html#Splitter-SplittingaCollection,Iterato
rorArray
#3: https://camel.apache.org/aggregator.html
    Should also be possibly as strategyRef option on the splitter, but I
havent it found as fast as this ;)


Jan

> -----Ursprüngliche Nachricht-----
> Von: mattmadhavan [mailto:mattmadhavan@yahoo.com]
> Gesendet: Mittwoch, 20. August 2014 23:52
> An: users@camel.apache.org
> Betreff: Camel Custom Splitter Question
> 
> Hello,
> I want to able be able to write a custom  splitter such that:
> 1) A message with  collection is broken down into individual
> message(exchange)
> 2) Based on the content of the message add a Message header.
> 3) Aggregate the split messages using the message header as the
> strategy.
> 
> The only way I see is to use a content enricher/processor to perform
> step 2). Is there a way to combine step 1) and 2)?
> 
> Or if there is any other idea I am all for it.
> 
> Can some one point me to the right direction please?
> 
> Thanks in advance!
> Matt
> 
> 
> 
> 
> 
> -----
> Thanks
> Matt G. Madhavan
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-
> Custom-Splitter-Question-tp5755453.html
> Sent from the Camel - Users mailing list archive at Nabble.com.