static void rcvSendChunkedSessMsg(CommsServerByteBuffer request,
                                      Conversation conversation,
                                      int requestNumber,
                                      boolean allocatedFromBufferPool,
                                      boolean sendReply)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "rcvSendSegmentedSessMsg",
                        new Object[] { request, conversation, requestNumber, allocatedFromBufferPool, sendReply });

        final boolean txOptimized = CommsUtils.requiresOptimizedTransaction(conversation);

        ConversationState convState = (ConversationState) conversation.getAttachment();
        ServerLinkLevelState linkState = (ServerLinkLevelState) conversation.getLinkLevelAttachment();
        ChunkedMessageWrapper wrapper = null;

        short connectionObjectId = request.getShort(); // BIT16 ConnectionObjectId
        short producerObjectId = request.getShort(); // BIT16 SyncProducerSessionId
        // Get the transaction id
        int transactionId = request.getSITransactionId(connectionObjectId, linkState, txOptimized);
        // Get the flags for the message
        byte flags = request.get();
        boolean first = ((flags & CommsConstants.CHUNKED_MESSAGE_FIRST) == CommsConstants.CHUNKED_MESSAGE_FIRST);
        boolean last = ((flags & CommsConstants.CHUNKED_MESSAGE_LAST) == CommsConstants.CHUNKED_MESSAGE_LAST);

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
        {
            SibTr.debug(tc, "connectionObjectId", connectionObjectId);
            SibTr.debug(tc, "producerObjectId", producerObjectId);
            SibTr.debug(tc, "transactionId", transactionId);
            SibTr.debug(tc, "flags", flags);
        }

        long wrapperId = getWrapperId(connectionObjectId, producerObjectId, transactionId);

        // If this is the first chunk of data, create a wrapper to save it in. Otherwise retrieve the
        // wrapper to append to.
        if (first)
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(tc, "This is the first chunk of data");

            // Get the transaction and produced session now and stash it away for later
            SITransaction siTran = linkState.getTransactionTable().get(transactionId);
            ProducerSession producer = ((ProducerSession) convState.getObject(producerObjectId));

            // Create a wrapper for this data to stash in the conversation state
            wrapper = new ChunkedMessageWrapper(siTran, producer);
            convState.putChunkedMessageWrapper(wrapperId, wrapper);
        }
        else
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(tc, "Appending to chunks already collected");
            wrapper = convState.getChunkedMessageWrapper(wrapperId);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(tc, "Appending to wrapper: ", wrapper);
        }

        // If the wrapper is null at this point, this is messed up
        if (wrapper == null)
        {
            SIErrorException e = new SIErrorException(
                            TraceNLS.getFormattedMessage(CommsConstants.MSG_BUNDLE, "CHUNK_WRAPPER_NULL_SICO2165", null, null)
                            );
            FFDCFilter.processException(e, CLASS_NAME + ".rcvSendSegmentedSessMsg",
                                        CommsConstants.STATICCATPRODUCER_SENDCHUNKED_01,
                                        "" + wrapperId);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(tc, "Chunked message wrapper is null!");
            throw e;
        }

        // Now get the chunk from the message and add it to the wrapper
        wrapper.addDataSlice(request.getDataSlice());

        // If this was the last slice we have received all the data we need and we must now send the
        // message into the bus and (possibly) send back a reply to the client.
        if (last)
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            {
                SibTr.debug(tc, "This is the last chunk - sending message");
                if (sendReply)
                    SibTr.debug(tc, "The client will be informed of the outcome");
                else
                    SibTr.debug(tc, "The client will NOT be informed of the outcome");
            }

            // Remove the chunks from the conversation state
            convState.removeChunkedMessageWrapper(wrapperId);

            try
            {
                // Recreate the message
                SIBusMessage sibMessage = JsMessageFactory.getInstance().createInboundJsMessage(wrapper.getMessageData());
                // And get all the info we need
                ProducerSession producer = wrapper.getProducerSession();
                SITransaction siTran = wrapper.getTransaction();

                try
                {

                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    {
                        SibTr.debug(tc, "Sending client message - " + sibMessage);
                        SibTr.debug(tc, "Destination: " + producer.getDestinationAddress());
                        SibTr.debug(tc, "Discriminator: " + sibMessage.getDiscriminator());
                        SibTr.debug(tc, "Reliability: " + sibMessage.getReliability());
                    }

                    if (siTran != IdToTransactionTable.INVALID_TRANSACTION)
                    {
                        producer.send(sibMessage, siTran);
                    }

                    if (sendReply)
                    {
                        try
                        {
                            conversation.send(poolManager.allocate(),
                                              JFapChannelConstants.SEG_SEND_CHUNKED_SESS_MSG_R,
                                              requestNumber,
                                              JFapChannelConstants.PRIORITY_MEDIUM,
                                              true,
                                              ThrottlingPolicy.BLOCK_THREAD,
                                              null);
                        } catch (SIException e)
                        {
                            FFDCFilter.processException(e,
                                                        CLASS_NAME + ".rcvSendSegmentedSessMsg",
                                                        CommsConstants.STATICCATPRODUCER_SENDCHUNKED_02);

                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                                SibTr.debug(tc, e.getMessage(), e);

                            SibTr.error(tc, "COMMUNICATION_ERROR_SICO2024", e);
                        }
                    }
                } catch (Exception e)
                {
                    // No FFDC code needed
                    // (actually we FFDC later on - but we need that line to fool the FFDC tool :-)

                    // If we are sending replies, rethrow the exception so
                    // that the specific exeption handlers will deal with it
                    // and send the response to the client
                    if (sendReply)
                        throw e;

                    // Otherwise, mark this transaction as error if we are not sending a reply
                    if (transactionId != CommsConstants.NO_TRANSACTION)
                        linkState.getTransactionTable().markAsRollbackOnly(transactionId, e);

                    //No FFDC code needed
                    //Only FFDC if we haven't received a meTerminated event OR if this Exception isn't a SIException.
                    if (!(e instanceof SIException) || !convState.hasMETerminated())
                    {
                        FFDCFilter.processException(e,
                                                    CLASS_NAME + ".rcvSendSegmentedSessMsg",
                                                    CommsConstants.STATICCATPRODUCER_SENDCHUNKED_03);
                    }

                    SibTr.error(tc, SibTr.Suppressor.ALL_FOR_A_WHILE_SIMILAR_INSERTS,
                                "UNABLE_TO_SEND_MESSAGE_SICO2009", e);

                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        SibTr.debug(tc, "Failed to send a message", e);
                }
            } catch (SIException e)
            {
                //No FFDC code needed - processor will have already FFDC'ed any interesting ones....
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(tc, e.getMessage(), e);

                StaticCATHelper.sendExceptionToClient(e,
                                                      CommsConstants.STATICCATPRODUCER_SENDCHUNKED_04,
                                                      conversation, requestNumber);

            } catch (Exception e)
            {
                FFDCFilter.processException(e,
                                            CLASS_NAME + ".rcvSendSegmentedSessMsg",
                                            CommsConstants.STATICCATPRODUCER_SENDCHUNKED_05);

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(tc, e.getMessage(), e);

                StaticCATHelper.sendExceptionToClient(e,
                                                      CommsConstants.STATICCATPRODUCER_SENDCHUNKED_05,
                                                      conversation, requestNumber);
            }
        }

        request.release(allocatedFromBufferPool);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "rcvSendSegmentedSessMsg");
    }
static void rcvSendChunkedSessMsg ( CommsServerByteBuffer request , Conversation conversation , int requestNumber , boolean allocatedFromBufferPool , boolean sendReply ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( tc , "rcvSendSegmentedSessMsg" , new Object [ ] { request , conversation , requestNumber , allocatedFromBufferPool , sendReply } ) ; final boolean txOptimized = CommsUtils . requiresOptimizedTransaction ( conversation ) ; ConversationState convState = ( ConversationState ) conversation . getAttachment ( ) ; ServerLinkLevelState linkState = ( ServerLinkLevelState ) conversation . getLinkLevelAttachment ( ) ; ChunkedMessageWrapper wrapper = null ; short connectionObjectId = request . getShort ( ) ; short producerObjectId = request . getShort ( ) ; int transactionId = request . getSITransactionId ( connectionObjectId , linkState , txOptimized ) ; byte flags = request . get ( ) ; boolean first = ( ( flags & CommsConstants . CHUNKED_MESSAGE_FIRST ) == CommsConstants . CHUNKED_MESSAGE_FIRST ) ; boolean last = ( ( flags & CommsConstants . CHUNKED_MESSAGE_LAST ) == CommsConstants . CHUNKED_MESSAGE_LAST ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { SibTr . debug ( tc , "connectionObjectId" , connectionObjectId ) ; SibTr . debug ( tc , "producerObjectId" , producerObjectId ) ; SibTr . debug ( tc , "transactionId" , transactionId ) ; SibTr . debug ( tc , "flags" , flags ) ; } long wrapperId = getWrapperId ( connectionObjectId , producerObjectId , transactionId ) ; if ( first ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "This is the first chunk of data" ) ; SITransaction siTran = linkState . getTransactionTable ( ) . get ( transactionId ) ; ProducerSession producer = ( ( ProducerSession ) convState . getObject ( producerObjectId ) ) ; wrapper = new ChunkedMessageWrapper ( siTran , producer ) ; convState . putChunkedMessageWrapper ( wrapperId , wrapper ) ; } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Appending to chunks already collected" ) ; wrapper = convState . getChunkedMessageWrapper ( wrapperId ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Appending to wrapper: " , wrapper ) ; } if ( wrapper == null ) { SIErrorException e = new SIErrorException ( TraceNLS . getFormattedMessage ( CommsConstants . MSG_BUNDLE , "CHUNK_WRAPPER_NULL_SICO2165" , null , null ) ) ; FFDCFilter . processException ( e , CLASS_NAME + ".rcvSendSegmentedSessMsg" , CommsConstants . STATICCATPRODUCER_SENDCHUNKED_01 , "" + wrapperId ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Chunked message wrapper is null!" ) ; throw e ; } wrapper . addDataSlice ( request . getDataSlice ( ) ) ; if ( last ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { SibTr . debug ( tc , "This is the last chunk - sending message" ) ; if ( sendReply ) SibTr . debug ( tc , "The client will be informed of the outcome" ) ; else SibTr . debug ( tc , "The client will NOT be informed of the outcome" ) ; } convState . removeChunkedMessageWrapper ( wrapperId ) ; try { SIBusMessage sibMessage = JsMessageFactory . getInstance ( ) . createInboundJsMessage ( wrapper . getMessageData ( ) ) ; ProducerSession producer = wrapper . getProducerSession ( ) ; SITransaction siTran = wrapper . getTransaction ( ) ; try { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { SibTr . debug ( tc , "Sending client message - " + sibMessage ) ; SibTr . debug ( tc , "Destination: " + producer . getDestinationAddress ( ) ) ; SibTr . debug ( tc , "Discriminator: " + sibMessage . getDiscriminator ( ) ) ; SibTr . debug ( tc , "Reliability: " + sibMessage . getReliability ( ) ) ; } if ( siTran != IdToTransactionTable . INVALID_TRANSACTION ) { producer . send ( sibMessage , siTran ) ; } if ( sendReply ) { try { conversation . send ( poolManager . allocate ( ) , JFapChannelConstants . SEG_SEND_CHUNKED_SESS_MSG_R , requestNumber , JFapChannelConstants . PRIORITY_MEDIUM , true , ThrottlingPolicy . BLOCK_THREAD , null ) ; } catch ( SIException e ) { FFDCFilter . processException ( e , CLASS_NAME + ".rcvSendSegmentedSessMsg" , CommsConstants . STATICCATPRODUCER_SENDCHUNKED_02 ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , e . getMessage ( ) , e ) ; SibTr . error ( tc , "COMMUNICATION_ERROR_SICO2024" , e ) ; } } } catch ( Exception e ) { if ( sendReply ) throw e ; if ( transactionId != CommsConstants . NO_TRANSACTION ) linkState . getTransactionTable ( ) . markAsRollbackOnly ( transactionId , e ) ; if ( ! ( e instanceof SIException ) || ! convState . hasMETerminated ( ) ) { FFDCFilter . processException ( e , CLASS_NAME + ".rcvSendSegmentedSessMsg" , CommsConstants . STATICCATPRODUCER_SENDCHUNKED_03 ) ; } SibTr . error ( tc , SibTr . Suppressor . ALL_FOR_A_WHILE_SIMILAR_INSERTS , "UNABLE_TO_SEND_MESSAGE_SICO2009" , e ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Failed to send a message" , e ) ; } } catch ( SIException e ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , e . getMessage ( ) , e ) ; StaticCATHelper . sendExceptionToClient ( e , CommsConstants . STATICCATPRODUCER_SENDCHUNKED_04 , conversation , requestNumber ) ; } catch ( Exception e ) { FFDCFilter . processException ( e , CLASS_NAME + ".rcvSendSegmentedSessMsg" , CommsConstants . STATICCATPRODUCER_SENDCHUNKED_05 ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , e . getMessage ( ) , e ) ; StaticCATHelper . sendExceptionToClient ( e , CommsConstants . STATICCATPRODUCER_SENDCHUNKED_05 , conversation , requestNumber ) ; } } request . release ( allocatedFromBufferPool ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "rcvSendSegmentedSessMsg" ) ; }
This method is invoked when we are processing the send of a chunked messsage is received by
the server. When the last chunk is received, the sendReply parameter is used to determine
whether a reply is expected to this overall send request.

@param request
@param conversation
@param requestNumber
@param allocatedFromBufferPool
@param sendReply