Greeting,
I do apologize in advance if this question has been posted before. I was
not able to find any relevant content. I have the following Route...
defined in this Java class...
Camel Version 2.10.0
Spring 3.0.7Release
velocity 1.7
/**
*
*/
package camelinaction;
import javax.jms.ConnectionFactory;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat;
import org.apache.camel.impl.DefaultCamelContext;
/**
* Main class to execute start the camel context and convert the csv file
* to a velocity template that can change over time.
* @author XGD93501 Garrett Deacon
*
*/
public class DynamicVelocityMain {
/**
* @param args
*/
public static void main(String[] args) {
// create CamelContext
CamelContext context = new DefaultCamelContext();
// connect to embedded ActiveMQ JMS broker
ConnectionFactory connectionFactory =
new ActiveMQConnectionFactory("vm://localhost");
context.addComponent("jms",
JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
// add our route to the CamelContext
try {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
// load file orders from src/data into the JMS
queue
BindyCsvDataFormat bindy = new
BindyCsvDataFormat("camelinaction");
from("file:src/data").unmarshal(bindy)
.process(new Processor() {
public void process(Exchange
exchange) throws Exception {
CustomerBean bean =
exchange.getIn(CustomerBean.class);
exchange.getIn().setBody(bean, CustomerBean.class);
}
})
.to("velocity:file:src/templates/doc.vm?contentCache=false")
.to("file:src/out");
// from("file:src/data").unmarshal(bindy)
//
.setHeader("CamelVelocityResourceUri").constant("file:src/templates/doc.vm?contentCache=false")
// .to("velocity:dummy")
// .to("file:src/out");
}
});
// start the route and let it do its work
context.start();
Thread.sleep(10000);
// stop the CamelContext
context.stop();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}//eom
}//eoc
I'm sending the result from bindy to a velocity template below...
The crazy brown fox jumped over the lazy cow
Hello, ${body.firstName} ${body.lastName}
When I look at the final file generated it does not resolve to the
properties of the CustomerBean. What am I doing wrong? Any help or
pointers greatly appreciated.
Thanks
--
View this message in context:
http://camel.465427.n5.nabble.com/Body-expression-not-resolving-to-bean-in-velocity-tp5768924.html
Sent from the Camel - Users mailing list archive at Nabble.com.