I've never seen or heard of javax.jms.Connection.start() blocking in that respect, and the JMS specification doesn't describe the behavior you expect. I think such behavior would be problematic in many use-cases (e.g. when you don't want to block). The whole point behind using a MessageListener is *not* to block.
There are lots of different ways to prevent your main() from exiting. Here are a few off the top of my head: 1) Wait for a specific bit of user input from the console. 2) Poll for a status file. 3) Use one of the many helpful objects in java.util.concurrent (e.g. CountDownLatch, Semaphore, one of the lock implementations in the locks package). Justin On Thu, Feb 21, 2019 at 8:06 AM Riyafa Abdul Hameed <riy...@apache.org> wrote: > Hi, > > I have the following asynchronous receiver for ActiveMQ Artemis: > https://gist.github.com/riyafa/7b0e5814286c60edb157f9a83fb64765 > > Here what I would expect when I call queueConn.start(); is that I want the > thread to wait to receive messages. I mean I don't want the main to exit > causing the program to shutdown. This is the expected behavior in JMS if I > am not mistaken because I noticed this behavior in other brokers. > > But with JMS in ActiveMQ Artemis I don't get the same behavior. The main > program exits even though I am calling connection.start(). Is there any > other way that I can use the MessageListener and not have the program exit > apart from using Thread.sleep? > > I am using artemis client 2.6.3. > > Thanks, > Riyafa >