camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: POJO Splitter - how to send multiple messages?
Date Tue, 16 Mar 2010 02:17:55 GMT
Which version of Camel are you using?
Here is an example of split the message in POJO.

  public List<Message> splitMessage(@Header(value = "user") String 
header, @Body String body) {
             // we can leverage the Parameter Binding Annotations
             // http://camel.apache.org/parameter-binding-annotations.html
             // to access the message header and body at same time,
             // then create the message that we want, splitter will
             // take care rest of them.
             // *NOTE* this feature requires Camel version >= 1.6.1
             List<Message> answer = new ArrayList<Message>();
             String[] parts = header.split(",");
             for (String part : parts) {
                 DefaultMessage message = new DefaultMessage();
                 message.setHeader("user", part);
                 message.setBody(body);
                 answer.add(message);
             }
             return answer;
         }

Willem

Klug, Johannes wrote:
> Dear list,
> 
> I am implementing a POJO splitter that takes one message as its input,
> and shall split this message into multiple output messages.
> 
> My route looks like this:
> 
> ...
> processor = new ContainerProcessor();
> from("direct:start").split().method(processor,
> "process").to(resultEndpoint);
> ...
> 
> Processor's process function returns List<Message>.
> However, no messages are received in resultEndpoint.
> 
> According to http://camel.apache.org/splitter.html, I need my own
> AggregationStrategy to combine the split messages. Unless there is a way
> to add more than one message to an exchange, this is not what I want - I
> just want a route that will produce n messages for each message put in.
> 
> Is there a way I can achieve this with Camel?
> 
> Thanks and kind regards,
> Johannes Klug
> 
> 
> 
> Please help Logica to respect the environment by not printing this email  / Pour contribuer
comme Logica au respect de l'environnement, merci de ne pas imprimer ce mail /  Bitte drucken
Sie diese Nachricht nicht aus und helfen Sie so Logica dabei, die Umwelt zu sch├╝tzen. / 
Por favor ajude a Logica a respeitar o ambiente nao imprimindo este correio electronico.
> 
> 
> 
> This e-mail and any attachment is for authorised use by the intended recipient(s) only.
It may contain proprietary material, confidential information and/or be subject to legal privilege.
It should not be copied, disclosed to, retained or used by, any other party. If you are not
an intended recipient then please promptly delete this e-mail and any attachment and all copies
and inform the sender. Thank you.
> 
> 


Mime
View raw message