try {
rc.sequenceManager().closeSequence(inboundSequence.getId());
final CloseSequenceResponseData.Builder responseBuilder = CloseSequenceResponseData.getBuilder(inboundSequence.getId());
// override the final sequence acknowledgement data as this sequence is not closed yet, but is closing already
Builder ackDataBuilder = AcknowledgementData.getBuilder(rc.destinationMessageHandler.getAcknowledgementData(inboundSequence.getId()));
ackDataBuilder.acknowledgements(inboundSequence.getId(), inboundSequence.getAcknowledgedMessageNumbers(), true);
inboundSequence.clearAckRequestedFlag();
responseBuilder.acknowledgementData(ackDataBuilder.build());
return rc.protocolHandler.toPacket(responseBuilder.build(), request, false);
} finally {
if (boundSequenceId != null) {
rc.sequenceManager().closeSequence(boundSequenceId);