On Tue, Apr 24, 2012 at 6:03 PM, Hynek Cihlar <[email protected]> wrote: > Hello all, > > what would be the best approach to solve the "transform and multiply" > behavior? That is, a message retrieved from an endpoint is transformed, > multiplied and sent down the route pipeline. >
What do you mean by multiplied? Do you mean the multicast EIP? http://camel.apache.org/multicast.html Or you can maybe split the message into X number of submessages and have each submessage send as email http://camel.apache.org/splitter > The closest I was able to come up myself is the following route config. It > probably also better explains the desired behavior. > You can also use a java bean and do a for loop in java code. And send a message using the producer template API. > <route> > <from uri="jms:emailOutbox"/> > <camel:loop copy="true"> > <xpath > resultType="java.lang.Integer">count(/net.phonemesh.integration.EmailMessage/to/string)</xpath>--> > <setHeader > headerName="to"><xpath>/net.phonemesh.integration.EmailMessage/to/string[${CamelLoopIndex}]/text()</xpath></setHeader> > <setHeader > headerName="from"><camel:constant>[email protected]</camel:constant></setHeader> > <setHeader > headerName="subject"><xpath>/net.phonemesh.integration.EmailMessage/subject/text()</xpath></setHeader> > > <setBody><xpath>/net.phonemesh.integration.EmailMessage/body/text()</xpath></setBody> > > <camel:removeHeaders pattern="JMS*"/> > <camel:removeHeaders pattern="breadcrumbId"/> > > > <camel:throttle timePeriodMillis="1000"> > <camel:constant>5</camel:constant> > <inOnly uri="smtps://mysmtpurl"/> > </camel:throttle> > </camel:loop> > </route> > > The little problem with the above is that it doesn't work :-). First, > ${CamelLoopIndex} is not resolved and second the throttling inside of the > loop doesn't seem to produce the expected behavior (instead of the expected > 5 email per second, it gives only 1 email a second). > > Any input is very welcome. > > Hynek > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Transform-and-multiply-tp5662517p5662517.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com FuseSource Email: [email protected] Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/
