Today’s Web Services are expected to work inspite of network failures and some sort of mechanism is required to ensure that messages are delivered properly inspite of such failures.Apart from that messages may be lost,duplicated or delivered in an incorrect order.WS-Reliable Messaging ensures guranteed message delivery between two endpoints.This is also referred to as the delivery assurance.There are four basic delivery assurances provided by the WS-RM
- At Most Once – Message will be delivered at most once without duplication or error will be thrown in at least one endpoint.
- At Least Once – Message will be delivered at least one point.
- Exactly Once – Message will be delivered without duplication in at least one endpoint.
- Ordered – Messages will be delivered in the order in which they were sent.
The diagram below provides a simple view of the Reliable Messaging model.
- Application source is the endpoint that sends the message.
- The RM source transmits the message over the wire.
- The RM destination is the endpoint that receives the message and also sends an acknowledgement of the receipt.
- RM Destination also delivers the message to the Application destination or the end point that is supposed to receive the message.
WS-RM defines the spec to achieve this flow by introducing additional elements in the SOAP message header.The major elements are
- Sequence – The sequence header block is key element used to track & assure message delivery.The main components of this are
- Identifier – This is an uniqueidentifier for the reliable session,which is used in all the subsequently exchanged messages.This is a must have element.
- MessageNumber – This is the ordinal position of the message within sequence.This is also a must have element.
- LastMessage – This indicates that a particular message is a last message in the sequence.
<wsrm:Sequence …>
<wsrm:Identifier …> xs:anyURI </wsrm:Identifier>
<wsrm:MessageNumber> xs:unsignedLong </wsrm:MessageNumber>
<wsrm:LastMessage/>
</wsrm:Sequence>
- SequenceAcknowledgement – On sucessful receipt of a message RM Destination sends a SequenceAcknowledgement.This can passed as an indepdent message or can be piggybacked with a operation response.The key elements of this are
- Identifier – This is the unique sequence identifier.This isa must element.
- AcknowledgementRange – Range of message numbers successfully received
- Nack – Unreceived message in the sequence.
<wsrm:SequenceAcknowledgement …>
<wsrm:Identifier …> xs:anyURI </wsrm:Identifier>
[ <wsrm:AcknowledgementRange … Upper=”xs:unsignedLong” Lower=”xs:unsignedLong”/> + |
<wsrm:Nack> xs:unsignedLong </wsrm:Nack> + ] …
</wsrm:SequenceAcknowledgement>
- CreateSequence – The RM Source creates the sequence by passing this message to the senders.
- CreateSequenceResponse – The RM destination responds to a CreateSequence request using this header block.This includes the Identifier element.
- SequenceTermination – After the RM Source receives acknowledgement of all the messages this message is sent out to inform the RM Destination that sequence will be terminated.based on this the RM Destination can release the resources.
The sequence of actions is somewhat like this:
The detailed specs can be found at:
specs.xmlsoap.org/ws/2005/02/rm/ws–reliablemessaging.pdf
In the next post I will discuss about how WCF implements this Reliable Messaging….