camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim83 <>
Subject Re: Using camel to send and alter MapMessage to a JMS queue
Date Thu, 04 Jun 2009 08:36:13 GMT

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">
			in.put("from", in.get("to"));
			in.put("to", in.get("toPdf"));

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:from uri="activemq:queue:incoming" />
		<camel:to uri="activemq:queue:service.A" />
				<camel:el>${in.body["somefield"] == "true"}</camel:el>
				<camel:process ref="messageProcessor" />
				<camel:to uri="activemq:queue:service.B"/>

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message