I am trying to configure Camel using Spring using only annotations and straight up Java. Here is a route I have created:
@Produce(uri = "activemq:my.route")
ProducerTemplate producer;
@RequestMapping(value = "/test", method = RequestMethod.POST)
public void testCamel()
{
producer.sendBody("TEST");
}
A camel context is needed, which I am trying to define in my AppConfig class:
My current version:
@Autowired
private ApplicationContext applicationContext;
@Bean
public CamelContext camelContext() throws Exception {
SpringCamelContext springCamelContext = new SpringCamelContext(applicationContext);
springCamelContext.addRoutes(new com.bigideas.routing.Routes());
return springCamelContext;
}
The Routes class is just an empty class that extends RouteBuilder.
The problem is that when I actually call the testCamel method, my producer is null. I know I can do the context in an xml configuration file, I was just wondering what I am doing wrong when not using xml.