I don't find a way to manipulate the MapMessage with Spring XML file.
But you can leverage the Processor to get back the control :)

<camel:route>
        <camel:from uri="activemq:queue:incoming" />
        <camel:pipeline>
                <camel:to uri="activemq:queue:service.A" />
                <camel:choice>
                        <camel:when>
                           <camel:el>${in.body["somefield"] == 
"true"}</camel:el>
                           <camel:process ref="changeMessageBody"/>
                           <camel:to uri="activemq:queue:service.B"/>
                        </camel:when>
                </camel:choice>
        </camel:pipeline>                       
 </camel:route>

 <bean id="changeMessageBody" class="MyProcessor"/>

 public class MyProcessor implements Processor {

    public void process(Exchange exchange) throws Exception {
        Map map = (Map) exchange.getIn().getbody();
        // do what you want on this map
        // set the map to the exchange
        exchange.getOut().setBody(map);
    }

}

Willem

Tim83 wrote:
> Hi all,
> 
> I'm having some troubles sending a MapMessage to a activemq queue using
> camel 1.6.
> 
> basicly what I'm trying to achieve is
> 
> I have an incoming map message, that first needs to go to service A, then to
> service B (optional).
> Once the message has been processed by service A, some fields in the map
> message need to be changed, in order for service B to handle it properly.
> 
> I've tried to configure this using the following XML, however I cannot get
> it to create the correct map message containing the correct information to
> send it to service B.
> 
> The incoming message contains 
> {source=c:\somefile.txt, to=c:\somefile2.txt, toextra=c:\somefile3.txt}
> 
> However for service B the map should become
> {source=c:\somefile2.txt, to=c:\somefile3.txt}
> 
> Is it possible to do this with camel using the xml config? Because I can't
> seem to find out how? :(
> 
> <camel:route>
>       <camel:from uri="activemq:queue:incoming" />
>       <camel:pipeline>
>               <camel:to uri="activemq:queue:service.A" />
>               <camel:choice>
>                       <camel:when>
>                               <camel:el>${in.body["somefield"] == 
> "true"}</camel:el>
>                               <camel:setBody>
>                                       <camel:el>what to put here?</camel:el>  
>                         
>                               </camel:setBody>
>                               <camel:to uri="activemq:queue:service.B"/>
>                       </camel:when>
>               </camel:choice>
>       </camel:pipeline>                       
> </camel:route>
> 
> Thanks,
> 
> Tim

Reply via email to