public synchronized SIBusMessage getMessage ( CommsConnection commsConnection ) throws SIResourceException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( tc , "getMessage" ) ; checkReleased ( ) ; SIBusMessage mess = null ; // Now build a JsMessage from the returned data. Note that a message length of -1 indicates // that no message has been returned and a null value should be returned to the caller. // Get length of JsMessage int messageLen = ( int ) getLong ( ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Message length" , messageLen ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Remaining in buffer" , receivedBuffer . remaining ( ) ) ; if ( messageLen > - 1 ) { // Build Message from byte array. If the buffer is backed by an array we should simply // pass that into MFP rather than copying into a new byte[] try { if ( receivedBuffer . hasArray ( ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Received buffer has a backing array" ) ; mess = JsMessageFactory . getInstance ( ) . createInboundJsMessage ( receivedBuffer . array ( ) , receivedBuffer . position ( ) + receivedBuffer . arrayOffset ( ) , messageLen , commsConnection ) ; // Move the position to the end of the message so that any data after the message // can be got receivedBuffer . position ( receivedBuffer . position ( ) + messageLen ) ; } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Received buffer does NOT have a backing array" ) ; byte [ ] messageArray = get ( messageLen ) ; mess = JsMessageFactory . getInstance ( ) . createInboundJsMessage ( messageArray , 0 , messageLen , commsConnection ) ; } } catch ( Exception e ) { FFDCFilter . processException ( e , CLASS_NAME + ".getMessage" , CommsConstants . COMMSBYTEBUFFER_GETMESSAGE_01 , this , new Object [ ] { "messageLen=" + messageLen + ", position=" + receivedBuffer . position ( ) + ", limit=" + receivedBuffer . limit ( ) + " " + ( receivedBuffer . hasArray ( ) ? "arrayOffset=" + receivedBuffer . arrayOffset ( ) + " array.length=" + receivedBuffer . array ( ) . length : "no backing array" ) } ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { SibTr . debug ( this , tc , "Unable to create message" , e ) ; dump ( this , tc , 100 ) ; } throw new SIResourceException ( e ) ; } } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "getMessage" , mess ) ; return mess ; }
Reads an SIBusMessage from the current position in the buffer .