void validateStopCloseForMessageListener ( String functionCall ) throws IllegalStateException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "validateStopForMessageListener" ) ; //Before triggering onMessage .. SIB pushes "owning session object" to Thread Local, //Now obtain the Session object from Thread Local and validate with 'this'. if ( ( JmsSessionImpl . asyncReceiverThreadLocal . get ( ) != null ) && ( JmsSessionImpl . asyncReceiverThreadLocal . get ( ) == this ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Message Listener onMessage called stop on its own Context/connection." ) ; if ( functionCall . equalsIgnoreCase ( "stop" ) ) { //stop is called. //the stop call is driven from this JmsSessionImpl object only.. throw JMSException throw ( IllegalStateException ) JmsErrorUtils . newThrowable ( IllegalStateException . class , "INVALID_METHOD_CWSIA0517" , new Object [ ] { this } , tc ) ; } else { //close is called //the stop call is driven from this JmsSessionImpl object only.. throw JMSException throw ( IllegalStateException ) JmsErrorUtils . newThrowable ( IllegalStateException . class , "INVALID_METHOD_CWSIA0518" , new Object [ ] { this } , tc ) ; } } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "validateStopForMessageListener" ) ; }
A message listener must not attempt to stop its own connection or context as this would lead to deadlock . IllegalStateException has to be thrown in case if it calls stop . THIS FUNCTION is called only in non - managed environments .