public static void sendSessionCreateResponse(int segmentType, int requestNumber,
                                                 Conversation conversation, short sessionId,
                                                 DestinationSession session,
                                                 SIDestinationAddress originalDestinationAddr) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "sendSessionCreateResponse");

        CommsByteBuffer buffer = poolManager.allocate();

        // Add the Message processor session id if we are sending back a consumer response
        if (segmentType == JFapChannelConstants.SEG_CREATE_CONS_FOR_DURABLE_SUB_R ||
            segmentType == JFapChannelConstants.SEG_CREATE_CONSUMER_SESS_R) {
            long id = 0;
            try {
                id = ((ConsumerSession) session).getId();
            } catch (SIException e) {
                //No FFDC code needed
                //Only FFDC if we haven't received a meTerminated event.
                if (!((ConversationState) conversation.getAttachment()).hasMETerminated()) {
                    FFDCFilter.processException(e, CLASS_NAME + ".sendSessionCreateResponse",
                                                CommsConstants.STATICCATHELPER_SENDSESSRESPONSE_02);
                }

                // Not a lot we can do here - so just debug the error
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(tc, "Unable to get session id", e);
            }
            buffer.putLong(id);
        }

        if (segmentType == JFapChannelConstants.SEG_CREATE_CONSUMER_SESS_R) {
            buffer.putShort(CommsConstants.CF_UNICAST);
        }

        buffer.putShort(sessionId);

        // Now get the destination address from the session so we can get sizes
        JsDestinationAddress destAddress = (JsDestinationAddress) session.getDestinationAddress();

        // We should only send back the destination address if it is different from the original.
        // To do this, we can do a simple compare on their toString() methods.
        if (originalDestinationAddr == null ||
            (!originalDestinationAddr.toString().equals(destAddress.toString()))) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(tc, "Destination address is different: Orig, New",
                            new Object[]
                            {
                             originalDestinationAddr,
                             destAddress
                            });

            buffer.putSIDestinationAddress(destAddress, conversation.getHandshakeProperties().getFapLevel());
        }

        try {
            // Send the response to the client.
            conversation.send(buffer,
                              segmentType,
                              requestNumber,
                              JFapChannelConstants.PRIORITY_MEDIUM,
                              true,
                              ThrottlingPolicy.BLOCK_THREAD,
                              null);
        } catch (SIException e) {
            FFDCFilter.processException(e,
                                        CLASS_NAME + ".sendSessionCreateResponse",
                                        CommsConstants.STATICCATHELPER_SENDSESSRESPONSE_01);

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

            SibTr.error(tc, "COMMUNICATION_ERROR_SICO2023", e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "sendSessionCreateResponse");
    }
public static void sendSessionCreateResponse ( int segmentType , int requestNumber , Conversation conversation , short sessionId , DestinationSession session , SIDestinationAddress originalDestinationAddr ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( tc , "sendSessionCreateResponse" ) ; CommsByteBuffer buffer = poolManager . allocate ( ) ; if ( segmentType == JFapChannelConstants . SEG_CREATE_CONS_FOR_DURABLE_SUB_R || segmentType == JFapChannelConstants . SEG_CREATE_CONSUMER_SESS_R ) { long id = 0 ; try { id = ( ( ConsumerSession ) session ) . getId ( ) ; } catch ( SIException e ) { if ( ! ( ( ConversationState ) conversation . getAttachment ( ) ) . hasMETerminated ( ) ) { FFDCFilter . processException ( e , CLASS_NAME + ".sendSessionCreateResponse" , CommsConstants . STATICCATHELPER_SENDSESSRESPONSE_02 ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Unable to get session id" , e ) ; } buffer . putLong ( id ) ; } if ( segmentType == JFapChannelConstants . SEG_CREATE_CONSUMER_SESS_R ) { buffer . putShort ( CommsConstants . CF_UNICAST ) ; } buffer . putShort ( sessionId ) ; JsDestinationAddress destAddress = ( JsDestinationAddress ) session . getDestinationAddress ( ) ; if ( originalDestinationAddr == null || ( ! originalDestinationAddr . toString ( ) . equals ( destAddress . toString ( ) ) ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Destination address is different: Orig, New" , new Object [ ] { originalDestinationAddr , destAddress } ) ; buffer . putSIDestinationAddress ( destAddress , conversation . getHandshakeProperties ( ) . getFapLevel ( ) ) ; } try { conversation . send ( buffer , segmentType , requestNumber , JFapChannelConstants . PRIORITY_MEDIUM , true , ThrottlingPolicy . BLOCK_THREAD , null ) ; } catch ( SIException e ) { FFDCFilter . processException ( e , CLASS_NAME + ".sendSessionCreateResponse" , CommsConstants . STATICCATHELPER_SENDSESSRESPONSE_01 ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , e . getMessage ( ) , e ) ; SibTr . error ( tc , "COMMUNICATION_ERROR_SICO2023" , e ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "sendSessionCreateResponse" ) ; }
Because of the larger amount of data needed to be sent back on the response to a session
create, I have split this into a seperate method so that we are not repeating code
all over the place.

@param segmentType The segment type to send the response with.
@param requestNumber The request number we are replying to.
@param conversation The conversation to send the reply on.
@param sessionId The session id of the session we just created.
@param session The session.
@param originalDestinationAddr The original address that was passed in. We will only send back
a destination address if the actual one is different.