Of course. Thanks for the prompt response. I cannot believe I let something so obvious slip through.
On Wed, Apr 26, 2017 at 11:03 AM, Claus Ibsen-2 [via Camel] < [email protected]> wrote: > Hi > > That is because the ctr is creating a local instance, eg > > CamelContext camelContext = new DefaultCamelContext(); > > should be > > camelContext = new DefaultCamelContext(); > > On Wed, Apr 26, 2017 at 11:59 AM, gelawlor <[hidden email] > <http:///user/SendEmail.jtp?type=node&node=5798308&i=0>> wrote: > > > Hi, > > > > I am implementing a Camel based connector service to ActiveMQ and the > class > > outline looks as follows: > > > > public class ActiveMQCamelRouterService { > > > > private CamelContext camelContext; > > private ProducerTemplate camelTemplate; > > > > > > public ActiveMQCamelRouterService() > > { > > try > > { > > CamelContext camelContext = new > DefaultCamelContext(); > > ActiveMQComponent queue = > > ActiveMQComponent.activeMQComponent("tcp://localhost:61616?broker.persistent=false"); > > > queue.setBrokerURL("tcp://localhost:61616"); > > camelContext.addComponent("activemq", queue); > > camelTemplate = camelContext.createProducerTemplate(); > > } > > catch(...) > > { > > } > > } > > > > public void process(SOAPEnvelope req, SOAPEnvelope resp) throws > > Exception { > > try > > { > > Node requestNode = getMessageNode(req); > > if(requestNode!=null) > > { > > final String routeSource = > "direct:activemq"; > > final String routeDestination = > "activemq:queue:testqueue"; > > > > if( camelContext != null ) > > { > > camelContext.addRoutes(new > RouteBuilder() { > > public void configure() throws > Exception { > > > > from(routeSource).to(routeDestination); > > > } > > }); > > > > camelContext.start(); > > > > //need to understand how to shape message with > headers to > > activemq through camel > > camelTemplate.sendBody(routeSource, "This is a > test message > > from Camel"); > > } > > > > } > > } > > catch(...) > > } > > > > What I have noticed is that the Camel context is initialized in the > > constructor but is NULL when the process method is called. I have tested > > this code instantiating other objects in the constructor and can see > they > > are valid in the process method. Do you know if this is a known issue or > > design feature of Camel ? Would this happen if somehow I got the mix of > jars > > (Camel, Camel-ActiveMQ and Spring) matched up incorrectly? > > > > Thanks, > > Ger. > > > > > > > > -- > > View this message in context: http://camel.465427.n5.nabble. > com/Camel-context-NULL-in-derived-class-tp5798307.html > > Sent from the Camel - Users mailing list archive at Nabble.com. > > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > http://camel.465427.n5.nabble.com/Camel-context-NULL-in-derived-class- > tp5798307p5798308.html > To unsubscribe from Camel context NULL in derived class, click here > <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5798307&code=Z2VyLmxhd2xvckBnbWFpbC5jb218NTc5ODMwN3wxMjgxNjExMjA0> > . > NAML > <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://camel.465427.n5.nabble.com/Camel-context-NULL-in-derived-class-tp5798307p5798309.html Sent from the Camel - Users mailing list archive at Nabble.com.
