You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by niteshjain <ni...@gmail.com> on 2015/02/11 06:45:54 UTC
Invoke a Route on bundle StartUp
Server - Jboss Fuse 6.0
Trying to invoke a route when the ApplicationContext is loaded successfully
using ApplicationContextAware Interface.
package com.test;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.impl.DefaultExchange;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class ContextAware implements ApplicationContextAware {
public static CamelContext context;
public static CamelContext getContext() {
return context;
}
public static void setContext(CamelContext context) throws Exception {
ContextAware.context = context;
}
public void setApplicationContext(ApplicationContext ac) throws
BeansException {
try {
ContextAware.setContext((CamelContext)
ac.getBean("hazel_camel"));
System.out.println("-----------Invoking
route----------------");
ProducerTemplate template =
ContextAware.context.createProducerTemplate();
Exchange exchange=new DefaultExchange(ContextAware.context);
template.send("*direct:getMessageProcessor*",exchange);
System.out.println("-----------END----------------");
} catch (Exception e) {
e.printStackTrace();
}
}
}
the "*direct:getMessageProcessor*" is not invoking the processor associated
with it in camel_context.xml :
<camelContext trace="false" id="camel"
xmlns="http://camel.apache.org/schema/spring">
<route id="getMessageProcessor">
<from uri="direct:getMessageProcessor" />
<process ref="getMessage" />
</route>
</camelContext>
<bean id="getMessage"
class="<b>com.test.GetMessageProcessor*" />
i get this in log -
org.apache.camel.camel-core - 2.12.0.redhat-610379 | Route:
getMessageProcessor started and consuming from:
Endpoint[*direct://getMessageProcessor*]
but GetMessageProcessor.java is not invoked,
Thanks,
Nitesh
--
View this message in context: http://camel.465427.n5.nabble.com/Invoke-a-Route-on-bundle-StartUp-tp5762580.html
Sent from the Camel - Users mailing list archive at Nabble.com.