private void setAsyncListener ( MessageListener listener ) throws JMSException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "setAsyncListener" , listener ) ; consumer = new Consumer ( listener , session , sessionAckMode ) ; try { // ConsumerSession must be stopped to register the callback coreConsumerSession . stop ( ) ; int batchSize = 1 ; boolean deliverImmediately = false ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Registering async callback for consumer" + consumer ) ; // the register call will replace any existing callback, so no need for // separate deregister call. coreConsumerSession . registerAsynchConsumerCallback ( consumer , 0 , // maxActiveMessages - no limit 0 , // messageLockExpiry - no expiry batchSize , session . getOrderingContext ( ) ) ; // Deal with the case where the listener is set after the connection // is started. Note that this will handle the restarting of the core // consumer session if we paused it earlier in this block. if ( session . getState ( ) == STARTED ) coreConsumerSession . start ( deliverImmediately ) ; } catch ( SIIncorrectCallException sie ) { // No FFDC code needed // d222942 review. Default message ok. // d238447 FFDC Review. FFDC here, see comment in next catch for more detail. throw ( JMSException ) JmsErrorUtils . newThrowable ( JMSException . class , "EXCEPTION_RECEIVED_CWSIA0085" , new Object [ ] { sie , "JmsMsgConsumerImpl.setAsyncListener" } , sie , "JmsMsgConsumerImpl.setAsyncListener#1" , this , tc ) ; } catch ( SIException sie ) { // No FFDC code needed // The exceptions thrown by stop, registerAsynchConsumerCallback and start are mostly // the "connection lost" family. registerAsynchConsumerCallback can also throw an // SIIncorrectCallException if the coreConsumerSession hasn't been stopped, but that // shouldn't be possible in the code above. Default message ok. // d238447 FFDC Review. SIIncorrectCall separated into its own catch block above, // no FFDCs for this group. throw ( JMSException ) JmsErrorUtils . newThrowable ( JMSException . class , "EXCEPTION_RECEIVED_CWSIA0085" , new Object [ ] { sie , "JmsMsgConsumerImpl.setAsyncListener" } , sie , null , // null probeId = no FFDC this , tc ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "setAsyncListener" ) ; }
internal method for assigning a message listener