com.inspirel.yami
Class IncomingMessage

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

public class IncomingMessage
extends java.lang.Object

Incoming message.

The handler allowing to inspect the details of the incoming message and sent back replies or rejection notifications.

The user code interacts with objects of this type mainly in callbacks that are provided during object registration and that are later called back when the incoming message arrives. The handler objects can be stored aside for further processing even after the callback returns, but should no be used after the agent itself is closed.

Note: The objects of this class are not supposed to be used from multiple threads.


Method Summary
 java.lang.String getMessageName()
          Get the message name.
 java.lang.String getObjectName()
          Get the destination object name.
 Parameters getParameters()
          Get the message parameters (message body).
 byte[] getRawContent()
          Get the message raw (binary) content.
 java.lang.String getSource()
          Get the target name of the message sender (the message source).
 void reject(java.lang.String reason)
          Send back the rejection (exception) notification with default (lowest) priority.
 void reject(java.lang.String reason, int priority)
          Send back the rejection (exception) notification with given priority.
 void reply(YAMISerializable replyBody)
          Send back the reply with default (lowest) priority.
 void reply(YAMISerializable replyBody, int priority)
          Send back the reply with given priority.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSource

public java.lang.String getSource()
Get the target name of the message sender (the message source).

Returns:
source name

getObjectName

public java.lang.String getObjectName()
Get the destination object name.

Returns:
destination object name

getMessageName

public java.lang.String getMessageName()
Get the message name.

Returns:
message name

getParameters

public Parameters getParameters()
Get the message parameters (message body).

Returns:
message parameters

getRawContent

public byte[] getRawContent()
Get the message raw (binary) content.

Returns:
message raw content
Throws:
BadStateException - if the agent was not configured for raw content delivery

reply

public void reply(YAMISerializable replyBody)
           throws YAMIIOException
Send back the reply with default (lowest) priority.

Parameters:
replyBody - the content of the reply (it can be null, in which case the empty object is sent)
Throws:
YAMIIOException - if the reply channel cannot be established

reply

public void reply(YAMISerializable replyBody,
                  int priority)
           throws YAMIIOException
Send back the reply with given priority.

Parameters:
replyBody - the content of the reply (it can be null, in which case the empty object is sent)
priority - the priority of reply
Throws:
YAMIIOException - if the reply channel cannot be established

reject

public void reject(java.lang.String reason)
            throws YAMIIOException
Send back the rejection (exception) notification with default (lowest) priority.

Parameters:
reason - arbitrary text that will be visible by the original sender as a reason for rejection
Throws:
YAMIIOException - if the reply channel cannot be established

reject

public void reject(java.lang.String reason,
                   int priority)
            throws YAMIIOException
Send back the rejection (exception) notification with given priority.

Parameters:
reason - arbitrary text that will be visible by the original sender as a reason for rejection
priority - the priority of rejection
Throws:
YAMIIOException - if the reply channel cannot be established