camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hynek Cihlar <hynek.cih...@gmail.com>
Subject Transform and multiply
Date Tue, 24 Apr 2012 16:03:47 GMT
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.

The closest I was able to come up myself is the following route config. It
probably also better explains the desired behavior.

        <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@example.com</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.

Mime
View raw message