Within the method onMessage 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 CallbackConnection-Factory object.
Within the actual thread you can use this connection handle like a normal client connection (see Client Programming Model).