Read data from a external Message Queue inside WAS
I would like to know the simplest approach for connection to and reading data from an external message queue inside WAS. Have you guys any information to share on this?
Usually it's not recommended to start threads from within J2EE applications. Since in that you interfere with the server management resources. It's forbidden by the EJB specification to do so from a bean in the EJB container.
The recommended way to receive messages is via MDB - whenever your application is started it will start receiving messages from your destination and the server will start invoking your onMessage() method.
Just have a look at any MDB/JMS tutorial.
The "not recommended" way is to start a new thread and to poll there from your destination by using synchronous JMS message listeners (like for example a call to receiver.receiveNoWait()) or by registering your own implementation of asynchronous MessageListeners (that by the way is very close to the MDB idea, however you will not be able to benefit from the built-in MDB scaling, performance benefits, transaction and security handling that can be easily tuned with your deployment descriptors even after the application has been created)