Claus Ibsen-2 wrote > > On Tue, Apr 24, 2012 at 6:03 PM, Hynek Cihlar <hynek.cihlar@> 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 >
Claus, thank you for your response. The multicast pattern in this case is not a valid option. The message must be transformed in a loop as shows the following pseudo code. * message is retrieved from the uplink processor * message is xpath-queried for a list of values * for each value queried above * the message is transformed with the current item from the queried list * message is sent down the pipeline Now the splitter can't be used either, because the transformation is an arbitrary operation, not a simple split. Also producer template in a bean won't do it either, because we need the process to be configurable through Spring config and flexible to be used in several scenarios; as an example, the pipeline "bellow" may vary from a simple component, to a throttler/wire tap/load balancer. Hynek Claus Ibsen-2 wrote > > 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>mailer@</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: cibsen@ > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/ > -- View this message in context: http://camel.465427.n5.nabble.com/Transform-and-multiply-tp5662517p5664936.html Sent from the Camel - Users mailing list archive at Nabble.com.
