com.inspirel.yami
Class OutgoingMessage

java.lang.Object
  extended by com.inspirel.yami.OutgoingMessage

public final class OutgoingMessage
extends java.lang.Object

Outgoing message.

The handler (proxy) allowing to track the progress of outgoing message, inspect its state and to obtain the reply content.

Note: The objects of this class can be safely used from multiple threads.


Nested Class Summary
static class OutgoingMessage.MessageState
          Enumeration defining all possible message states.
static class OutgoingMessage.MessageStateInfo
          Helper class for reporting full message state
 
Method Summary
 void close()
          Cleans up internal resources related to this message.
 java.lang.String getExceptionMsg()
          Gets the rejection reason for this message
 byte[] getRawReply()
          Gets the raw reply body.
 Parameters getReply()
          Gets the reply body.
 OutgoingMessage.MessageState getState()
          Gets the current state of the message.
 OutgoingMessage.MessageStateInfo getStateInfo()
          Gets the current state and information about the message progress.
 void waitForCompletion()
          Waits for the completion of this message.
 boolean waitForCompletion(long relativeTimeout)
          Waits for the completion of this message.
 boolean waitForCompletionAbsolute(long absoluteTimeout)
          Waits for the completion of this message.
 void waitForTransmission()
          Waits for the transmission of this message.
 boolean waitForTransmission(long relativeTimeout)
          Waits for the transmission of this message.
 boolean waitForTransmissionAbsolute(long absoluteTimeout)
          Waits for the transmission of this message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getState

public OutgoingMessage.MessageState getState()
Gets the current state of the message.

Returns:
current state

getStateInfo

public OutgoingMessage.MessageStateInfo getStateInfo()
Gets the current state and information about the message progress.

Returns:
current state info

getReply

public Parameters getReply()
Gets the reply body.

Returns:
reply body if the current state is REPLIED
Throws:
BadStateException - if the current state is not REPLIED

getRawReply

public byte[] getRawReply()
Gets the raw reply body.

Returns:
reply body if the current state is REPLIED
Throws:
BadStateException - if the current state is not REPLIED or if the agent was not configured for raw delivery

getExceptionMsg

public java.lang.String getExceptionMsg()
Gets the rejection reason for this message

Returns:
rejection reason (or exception message) if the current state is REJECTED
Throws:
BadStateException - if the current state is not REJECTED

waitForTransmission

public void waitForTransmission()
Waits for the transmission of this message.

Note: The wait is terminated either when the transmission is successful or when the message is cancelled due to error or channel closing request.


waitForTransmission

public boolean waitForTransmission(long relativeTimeout)
Waits for the transmission of this message.

Note: The wait is terminated either when the transmission is successful or when the message is cancelled due to error or channel closing request or when the timeout expires.

Parameters:
relativeTimeout - relative timeout in milliseconds
Returns:
false if the timeout has expired

waitForTransmissionAbsolute

public boolean waitForTransmissionAbsolute(long absoluteTimeout)
Waits for the transmission of this message.

Note: The wait is terminated either when the transmission is successful or when the message is cancelled due to error or channel closing request or when the timeout expires.

Parameters:
absoluteTimeout - absolute timeout in milliseconds, counted from the beginning of the epoch (UTC)
Returns:
false if the timeout has expired

waitForCompletion

public void waitForCompletion()
Waits for the completion of this message.

Note: The wait is terminated either when the message is completed - which means that there was a reply or rejection received for it - or when the message is cancelled due to error or channel closing request.


waitForCompletion

public boolean waitForCompletion(long relativeTimeout)
Waits for the completion of this message.

Note: The wait is terminated either when the message is completed - which means that there was a reply or rejection received for it - or when the message is cancelled due to error or channel closing request or when the timeout expires.

Parameters:
relativeTimeout - relative timeout in milliseconds
Returns:
false if the timeout has expired

waitForCompletionAbsolute

public boolean waitForCompletionAbsolute(long absoluteTimeout)
Waits for the completion of this message.

Note: The wait is terminated either when the message is completed - which means that there was a reply or rejection received for it - or when the message is cancelled due to error or channel closing request or when the timeout expires.

Parameters:
absoluteTimeout - absolute timeout in milliseconds, counted from the beginning of the epoch (UTC)
Returns:
false if the timeout has expired

close

public void close()
Cleans up internal resources related to this message.