Package com.softwareag.entirex.aci
Class BrokerMessage
- java.lang.Object
-
- com.softwareag.entirex.aci.BrokerMessage
-
public class BrokerMessage extends java.lang.Object
This class encapsulates a single message, which will be sent to or received from another participant via the EntireX Broker.
The contents of a message is always a byte array. Constructors and methods, which provide a transformation between byte arrays and String objects, are available.
When the message has been created as the result of a successful receive or sendReceive call, thegetService()
,getConversation()
andgetUnitofWork()
methods can be used to navigate to the context of the received message.
-
-
Constructor Summary
Constructors Constructor Description BrokerMessage()
Creates a Message object with an empty message.BrokerMessage(byte[] msg)
Creates a Message object initialized with the passed byte array.BrokerMessage(java.lang.String msg)
Creates a BrokerMessage object initialized with the passed String object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getClientUID()
Returns the client's user ID.Conversation
getConversation()
Returns the corresponding Conversation object.java.lang.String
getCorrelationID()
Returns the correlation ID for this message if available.
The correlation ID is only available if this message is a reply message to a previous request message.byte[]
getMessage()
Returns the current message as a byte array.java.lang.String
getMessageID()
Returns the unique message ID of this message.
This message ID is passed only to a Broker version 10.1 or higher.BrokerService
getService()
Returns the BrokerService object to which the message belongs.UnitofWork
getUnitofWork()
Returns the corresponding UnitofWork object.void
reply(BrokerMessage msg)
Sends a reply to a previously received message.void
setMessage(byte[] s)
Sets the current message to the passed byte array.void
setMessage(java.lang.String s)
Sets the current message to the passed string.java.lang.String
toString()
Returns the current message as a string.
-
-
-
Constructor Detail
-
BrokerMessage
public BrokerMessage()
Creates a Message object with an empty message.
-
BrokerMessage
public BrokerMessage(byte[] msg)
Creates a Message object initialized with the passed byte array.- Parameters:
msg
- the message as byte array.
-
BrokerMessage
public BrokerMessage(java.lang.String msg)
Creates a BrokerMessage object initialized with the passed String object. The String object is converted to a byte array.- Parameters:
msg
- the message as a String object.
-
-
Method Detail
-
toString
public java.lang.String toString()
Returns the current message as a string.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The message data as a String or
null
.
-
getClientUID
public java.lang.String getClientUID()
Returns the client's user ID. Only available after a receive issued by a server application.- Returns:
- The client's user ID as a string or
null
.
-
getMessage
public byte[] getMessage()
Returns the current message as a byte array.- Returns:
- the message as a byte array or
null
.
-
setMessage
public void setMessage(byte[] s)
Sets the current message to the passed byte array.- Parameters:
s
- the message as byte array.
-
setMessage
public void setMessage(java.lang.String s)
Sets the current message to the passed string.- Parameters:
s
- the message as string.
-
getService
public BrokerService getService()
Returns the BrokerService object to which the message belongs. Only available when the Message object has been created by a receive or sendReceive call.- Returns:
- a reference to the BrokerService object.
-
getConversation
public Conversation getConversation()
Returns the corresponding Conversation object.
If the message has been created by a receive or sendReceive call and if the message is part of a conversational communication, this method returns the corresponding Conversation object. Otherwise,null
is returned.- Returns:
- a reference to the Conversation object or
null
.
-
getUnitofWork
public UnitofWork getUnitofWork()
Returns the corresponding UnitofWork object.
If the message has been created by a receive call and if the message is part of a UnitofWork communication, this method returns the corresponding UnitofWork object. Otherwise,null
is returned.- Returns:
- a reference to the Conversation object or
null
.
-
reply
public void reply(BrokerMessage msg) throws BrokerException
Sends a reply to a previously received message.
If the message has been created by a receive or sendReceive call and if the message is either the only message of a non-conversational communication or if the message is part of a conversational communication, this method sends a reply back to the originator of this message.- Parameters:
msg
- BrokerMessage to send.- Throws:
BrokerException
- A Broker exception.java.lang.IllegalArgumentException
- Thrown if the parameter is invalid.
-
getMessageID
public java.lang.String getMessageID()
Returns the unique message ID of this message.
This message ID is passed only to a Broker version 10.1 or higher.- Returns:
- the message ID of this message or null if it is not available.
-
getCorrelationID
public java.lang.String getCorrelationID()
Returns the correlation ID for this message if available.
The correlation ID is only available if this message is a reply message to a previous request message. The correlation ID of the reply message is identical to the message ID of the request message. A correlation ID is available only if all involved EntireX components are of version 10.1 or higher.- Returns:
- the correlation ID of this message or null if it is not available.
-
-