Hi everyone. I figured out the issue here (sort of). The camel main class 
appears to not provide the Camel context correctly when the 
getOrCreateCamelContext() is called. I tried for hours yesterday trying to make 
this give me the correct context so I could add the ActiveMQ component in with 
the correct remote URL.

I finally used the startup code from the article below (found it in the 
articles section of the site), thus replacing the use of the Camel Main class 
and it added the comment to the context and I was able to see my messages hit 
the queue on the remote ActiveMQ server.

http://saltnlight5.blogspot.com/2013/08/getting-started-with-apache-camel-using.html

Hope that helps anyone who runs up against a similar issue.

From: <Wilkerson>, Daniel Wilkerson 
<dwilker...@fullsail.com<mailto:dwilker...@fullsail.com>>
Date: Wednesday, April 1, 2015 11:53 AM
To: "users@camel.apache.org<mailto:users@camel.apache.org>" 
<users@camel.apache.org<mailto:users@camel.apache.org>>
Subject: Problem Adding ActiveMQ Broker URL to Camel Context Using Java DSL 
Type Project

I'm trying to add the correct tcp:// connection url to the camel context in a 
standalone/Java DSL camel app and am using a boot() method that was pulled from 
example code on the camel site. In my boot() method I'm trying to add the 
correct URL to the camel context but it's not getting added. When the code runs 
its still looking for a broker on localhost instead of the broker server I 
passed. How do I get the URL to be picked up in the context so my Java DSL 
route can connect to the correct server?

@SuppressWarnings("static-access")
public void boot() throws Exception {
        // create a Main instance
        main = new Main();
        // enable hangup support so you can press ctrl + c to terminate the JVM
        main.enableHangupSupport();
        ActiveMQComponent amq = new ActiveMQComponent();

        main.getOrCreateCamelContext().addComponent(
        "activemq",
        amq.activeMQComponent("tcp://ourbrokerserver.workplace.com:61616"));
        //ActiveMQComponent amq = new ActiveMQComponent();

        // add routes
        main.addRouteBuilder(new EtlProducerRouteBuilder());
        // run until you terminate the JVM
        System.out.println("Starting Camel. Use ctrl + c to terminate the 
JVM.\n");
        main.run();
    }

Reply via email to