Thanks for the hint!

I managed to get it working now.

I made a beanshell processor that can be used as a bean in with Spring XML

The xml config
<bean id="messageProcessor" class="processor.BeanShellProcessor">
        <property name="expression">
                <value>
                        in.put("from", in.get("to"));
                        in.put("to", in.get("toPdf"));
                </value>
        </property>                     
</bean>


The java code
import java.util.HashMap;

import org.apache.bsf.BSFManager;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;

public class BeanShellProcessor implements Processor {
        private String expression;
        
        public void process(Exchange ex) throws Exception {
                BSFManager manager = new BSFManager();
                manager.declareBean("in", ex.getIn().getBody(), HashMap.class);
                manager.exec("beanshell", "myScript.bsh", 0, 0, 
this.getExpression());
        }

        public String getExpression() {
                return expression;
        }

        public void setExpression(String expression) {
                this.expression = expression;
        }
}

Camel config
<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="messageProcessor" />
                                <camel:to uri="activemq:queue:service.B"/>
                        </camel:when>
                </camel:choice>
        </camel:pipeline>                       
</camel:route>

Tim
-- 
View this message in context: 
http://www.nabble.com/Using-camel-to-send-and-alter-MapMessage-to-a-JMS-queue-tp23850609p23865923.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to