|
|
In this scenario, the AtMostOnce delivery assurance allows the failed delivery of a message that is not followed up with another transmission attempt.
|
AtLeastOnce
|
|
The AtLeastOnce assurance allows a message to be delivered multiple times, but ensures that it is delivered at least once.
|
|
|
The AtLeastOnce assurance allowing a message to be sent twice.
|
ExactlyOnce
|
|
The ExactlyOnce delivery assurance requires that a message be delivered once only.
|
|
|
Here, a failed delivery is followed by another delivery attempt, which this time succeeds.
|
InOrder
|
|
The InOrder assurance can supplement any of the preceding by also guaranteeing that messages will be delivered in the sequence in which they were sent.
|
|
|
A set of messages being transmitted in a predefined sequence. In the previous example, the initial delivery of message 2 failed. It was then resent, as the sequence must be completed, as per the assurance rule.
|
|
For the receiver of a message to notify the sender as to whether the messages within a sequence were successfully delivered, it responds using acknowledgement messages.
|
|
|
One acknowledgement can be sent for each message received. Alternatively, you can opt to have the receiver wait until the sequence has completed, before responding with just one acknowledgement for all received messages within a sequence
|
|
|
Reliable messaging exists within SOAP header blocks, which are processed by SOAP receivers along a message path.
|
|
The parent Sequence construct implements reliable messaging information, as follows:
|
<wsrm:Sequence>
<wsu:Identifier>http://www.examples.ws/</wsu:Identifier>
<wsrm:MessageNumber>2</wsrm:MessageNumber>
<wsrm:LastMessage/>
</wsrm:Sequence>
|
|
In the preceding example, our Sequence header construct uses the Identifier element to assign a unique URI to the sequence. The MessageNumber element determines the position of the current message within the overall sequence order. This number increments with each subsequent message sent as part of a sequence. Finally, the LastMessage element identifies this message as the last one to be delivered.
|
|
A Sequence construct also can contain an optional Expires element that limits the validity of the sequence to a date and time value. Note that there can be only one Sequence construct in a SOAP message.
|
|
Though this example establishes a fundamental sequence header, there is still one part we have not yet addressed: the delivery assurance. This characteristic is implemented as a policy assurance, and then associated with the message as part of a policy attachment. We therefore demonstrate this portion of the example in the “WS -Policy” part of this article.
|
|
Note that other policy assertions can be attached to a sequence message header, including:
|
• sequence expiration
|
• inactivity timeout
|
|
• retransmission interval
|
|
An acknowledgement construct can be sent in a separate message, or as part of a response message. The parent SequenceAcknowledgement element hosts the same Identifier value, as well as the AcknowledgementRange element. This construct tells the original sender which of the messages in the sequence were delivered successfully, by specifying a range that corresponds to the number of messages in the sequence.
|
<wsrm:SequenceAcknowledgment>
<wsu:Identifier>http://www.examples.ws/</wsu:Identifier>
<wsrm:AcknowledgmentRange Upper="6" Lower="1"/>
</wsrm:SequenceAcknowledgment>
|
|
In this example, all six messages were successfully delivered. If, however, one of the messages in the sequence failed to arrive, the SequenceAcknowledgement construct may need to host a number of the AcknowledgementRange elements to identify only those that were delivered. Gaps in the sequence are considered failed deliveries.
|
<wsrm:SequenceAcknowledgment>
<wsu:Identifier>http://www.examples.ws/</wsu:Identifier>
<wsrm:AcknowledgmentRange Upper="3" Lower="1"/>
<wsrm:AcknowledgmentRange Upper="6" Lower="5"/>
</wsrm:SequenceAcknowledgment>
|
|
In our revised example, the SequenceAcknowledgement construct uses two AcknowledgementRange elements to communicate that messages 1, 2, 3, 5, and 6 were delivered. By omission, the delivery of message number 4 is assumed to have failed.
|
Delivery Assurances with WS-Policy
|
|
Policies help organize and apply rules and properties of Web services within diverse application environments. The WS-Policy standard establishes a series of conventions that are further extended through the WS-PolicyAssertions and WS-PolicyAttachments specifications. Collectively, these standards form the WS-Policy framework.
|
|
Polices are defined through individual policy assertions. Each assertion can communicate a particular preference, rule, capability, or requirement of service logic. A policy assertion is implemented syntactically through a policy expression.
|
|
Whatever part of the service to which a policy expression is applied to is referred to as the policy subject. Policy attachments are used to bind policy expressions to policy subjects.
|
|
To demonstrate a use for WS-Policy, let’s continue with the example from the WS-ReliableMessaging article.
|
|
The first message we assembled in the original example contained a sequence construct that provided information used for identification and sequencing purposes.
|
<wsrm:Sequence>
<wsu:Identifier>http://www.examples.ws/</wsu:Identifier>
<wsrm:MessageNumber>2</wsrm:MessageNumber>
<wsrm:LastMessage/>
</wsrm:Sequence>
|
|
To this base set of reliable messaging data we now want to add one of the predefined delivery assurances.
|
|
Through the use of WS-Policy, WS-PolicyAssertions, and WS-PolicyAttachments features, we can:
|
|
1. establish a policy expression using the policy construct
|
|
2. establish the delivery assurance value as a policy assertion within this expression
|
|
3. attach the expression to the existing sequence construct as a policy attachment
|
|
Essentially, we need to establish a policy based on the chosen delivery assurance, and then attach it to the sequence header block we created in the WS-ReliableMessaging example.
|
|
We begin with the PolicyAttachment parent construct that hosts the policy assertion to be attached to our sequence.
|
<wsp:PolicyAttachment>
<wsp:AppliesTo>
<wsrm:SequenceRef>
<wsu:Identifier>http://www.examples.ws/</wsu:Identifier>
</wsrm:SequenceRef>
</wsp:AppliesTo>
<wsp:Policy>
<wsrm:DeliveryAssurance Value="wsrm:AtLeastOnce"
wsp:Usage="wsp:Required"/>
</wsp:Policy>
...
</wsp:PolicyAttachment>
|
Here we identify the sequence to which we want to attach the delivery assurance, using the SequenceRef construct. The delivery assurance policy itself is then defined within the Policy construct.
|