Callback

Definition

Within the onMessage method of your MessageDrivenBean implementation you can use a call-back mechanism. As long as your call handling didn't change the thread, you may allocate CallbackConnectionFactory and receive a connection handle from there:

Context ctx = new InitialContext();  
ConnectionFactory connectionfactory =   
ConnectionFactory)ctx.lookup("CallbackConnectionFactory");
Connection connection = connectionfactory.getConnection();  
         

The String CallbackConnectionFactory is the JNDI name for the CallbackConnectionFactory object.

Within the actual thread you can use this connection handle like a normal client connection (refer to Client Programming Model ).