3.1.1.3.2 Stream Receipts

Stream receipts pertain to stream message sequences (section 3.1.1.2). The receiving QM sends a stream receipt to the sender in the form of a regular SRMP message that contains the <streamReceipt> element. The purpose of a stream receipt is to notify the sender that the receiving QM received a stream message and successfully stored it to disk. Stream receipts are always sent for stream messages; there is no SRMP message element for requesting stream receipts. A stream receipt can only be used to acknowledge messages from one stream.

The <streamReceipt> element contains a stream ID (in the <streamId> element) and a stream sequence number (in the <lastOrdinal> element) that specify the stream message being acknowledged. The receiver MUST acknowledge stream messages in sequence order. For example, if it receives messages 1, 2, and 4 within a sequence, it cannot send a receipt for message 4 until it receives message 3 and saves it to disk.

The receiving QM MUST durably store a stream message to disk before sending a stream receipt to the sender. A stream receipt will acknowledge multiple messages if there are multiple messages to acknowledge when the stream receipt is sent. For example, if the last acknowledged message was 5 and the receiver received and saved to disk messages 6, 7, and 8, then the receiver MAY set the <lastOrdinal> element to the value 8. The receiving QM waits a minimum of 500 milliseconds before sending a stream receipt message. If a new message on the same stream is received during this period, the stream receipt is delayed another 500 milliseconds. This process continues and can delay the stream receipt up to 10 seconds.

The <lastOrdinal> element specifies to the sender the highest message sequence number that was received by the receiver and saved to disk. The sender SHOULD discard its local copies of acknowledged stream messages up to the position in the sequence that the sender specified.