org.systinet.wasp.wsrm.sequence
Interface InputSequence

All Superinterfaces:
OneWaySequence, Sequence

public interface InputSequence
extends OneWaySequence

Used for incoming messages. On client, it is always part of DuplexSequence.

Since:
SSJ 6.5
Component:
WS Reliable Messaging Interfaces

Nested Class Summary
 
Nested classes inherited from class org.systinet.wasp.wsrm.sequence.OneWaySequence
OneWaySequence.MessageState, OneWaySequence.State
 
Field Summary
 
Fields inherited from interface org.systinet.wasp.wsrm.sequence.OneWaySequence
UNKNOWN_LENGTH
 
Method Summary
 void confirmCurrentMessage()
          Explicitly confirms the current message.
 void confirmMessage(long messageNumber)
          Explicitly confirms the given message.
 long getCurrentMessageNumber()
          Returns the sequence number of the currently processed message.
 boolean isExplicitConfirmation()
          Returns true when the explicit confirmation is enabled for this sequence.
 void setExplicitConfirmation(boolean explicitConfirmation)
          Enables the application to express its interest in explicit confirmation of messages.
 
Methods inherited from interface org.systinet.wasp.wsrm.sequence.OneWaySequence
abort, getExpires, getLength, getMessageState, getState, getWireId, isActive, isExpired, isOutput, setActive
 
Methods inherited from interface org.systinet.wasp.wsrm.sequence.Sequence
getID, setExpires
 

Method Detail

setExplicitConfirmation

public void setExplicitConfirmation(boolean explicitConfirmation)
                             throws SequenceException
Enables the application to express its interest in explicit confirmation of messages. If an explicit confirmation is set on an input sequence, application must confirm all messages by calling confirmCurrentMessage() or confirmMessage(long); otherwise the messages will be treated as unconfirmed and will be re-delivered to the application according to configured policy.

When the explicit confirmation is turned off (default), messages are implicitly confirmed as soon as the service invocation ends. Application may be still interested in earlier explicit input message confirmation in case the invocation takes longer time.

Note that messages are acknowledged as soon as they arrive to the destination machine. Confirmation of a message removes it from the input queue, so the message will not be processed second time in presence of server restart.

Explicit confirmation can be be setup in a sequence listener:
     private static class SequencesListener extends GenericSequenceListener {
         public void onCreate(OneWaySequence sequence) {
             if(!sequence.isOutput()) {
                 // for input (incoming) sequences only
                 try {
                     ((InputSequence)sequence).setExplicitConfirmation(true);
                 } catch (SequenceException e) {
                     e.printStackTrace();
                 }
             }
         }
     }
 

Throws:
SequenceException
See Also:
confirmCurrentMessage(), confirmMessage(long)

getCurrentMessageNumber

public long getCurrentMessageNumber()
Returns the sequence number of the currently processed message. The first message in a sequence has number 1.

Note that you can distinguish the last message of sequence by the expression sequence.getCurrentMessage() == sequence.getLength() although when not using in-order delivery assurance. This condition does not guarantee that some out of order messages will not arrive later. In such case, the expression sequence.getCurrentLength() == sequence.getLength() hints that there will be no more messages in a sequence (but remember, there can be a concurrent thread processing another message of the same sequence).

See Also:
OutputSequence.getCurrentLength()

isExplicitConfirmation

public boolean isExplicitConfirmation()
Returns true when the explicit confirmation is enabled for this sequence.

See Also:
setExplicitConfirmation(boolean)

confirmCurrentMessage

public void confirmCurrentMessage()
                           throws SequenceException
Explicitly confirms the current message.

Confirmation of input message results in state transition from MessageState#NOT_DELIVERED to MessageState#DELIVERED state.

Throws:
SequenceException
See Also:
setExplicitConfirmation(boolean)

confirmMessage

public void confirmMessage(long messageNumber)
                    throws SequenceException
Explicitly confirms the given message.

Confirmation of input message results in state transition from MessageState#NOT_DELIVERED to MessageState#DELIVERED state.

Throws:
SequenceException - when attempting to confirm a non-existing message (i.e. getMessageState(x) == OneWaySequence.MessageState.NOT_PRESENT)
See Also:
setExplicitConfirmation(boolean)