简体   繁体   中英

Camel only sends the message on startup, then stops

I have hopefully a trivial problem. I wrote super short 'program' for Apache Camel to read the context.xml and then do as it is told:

public class CamelBridge {
    public static void main(String[] args) throws Exception {
        ApplicationContext context = new FileSystemXmlApplicationContext("camelContext.xml");        
    }
}

I connect between two JMS queues. The program works, but just when I start it. Then it stops sending messages. If I restart- it sends them all again. Is there something oviously wrong that I am missing here?

Edit:

I have updated my Main, but it does not help:

public class Bridge {

    private Main main;

    public static void main(String[] args) throws Exception {
        Bridge bridge = new Bridge ();
        bridge.boot();
    }

    public void boot() throws Exception{
        main = new Main();
        main.enableHangupSupport(); 
        main.setApplicationContextUri("camelContext.xml");
        main.run();
    }
}

Edit 2

I think I found the issue (not the solution). After enabling tracing, I found the error message which reads:

jms cannot find object in dispatcher with id --some id--

And after some more digging I found that this is connected clientLeasePeriod in the remoting file. Any idea if it is possible to fix this kind of problem on Camel side?

You have to prevent JVM from finishing

Check this example: http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html

Provided you app contains only Main and xml file which configures Camel's context then context will be destroyed (so your routes destroyed as well). Even if different context run JMS implementation on same JVM. Sergey link should help you.

If you want just make it work to test things, add while(true) as a last line of your main. Note this is not the best approach :).

I realised that the problem was with the server on which the program was installed. The server thought that it resides on a public network, rather than private network (Windows Server 2012). After changing the network to private, the process worked correctly.

Note- the Camel did not give any errors regarding this, so this can be difficult to spot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM