public interface ImaMessage
Modifier and Type | Field and Description |
---|---|
static String |
COPYRIGHT |
Modifier and Type | Method and Description |
---|---|
void |
acknowledge(int rc)
Acknowledge a received message.
|
void |
acknowledge(int rc,
ImaTransaction transaction)
Acknowledge a received message.
|
ImaMessage |
addProperties(Map<String,Object> props)
Add to the properties of a message.
|
ImaMessage |
clearProperties()
Clear all user message properties.
|
byte[] |
getBodyBytes()
Get the body of the message as byte array.
|
Map<String,Object> |
getBodyMap()
Get the body of the message as a Map.
|
String |
getBodyText()
Get the body of the message as a String.
|
boolean |
getBooleanProperty(String name,
boolean default_value)
Get a message property as a boolean.
|
String |
getDestination()
Get the name of the destination the message was published to.
|
ImaDestinationType |
getDestinationType()
Get the type of the destination the message was published to.
|
int |
getIntPropery(String name,
int default_value)
Get a message property as an integer.
|
ImaMessageType |
getMessageType()
Get the type of the message body.
|
boolean |
getPersistence()
Get the persistence of the message.
|
Map<String,Object> |
getProperties()
Get a read-only map of the user message properties.
|
Object |
getProperty(String name)
Get a message property as an Object.
|
ImaReliability |
getReliability()
Get the reliability of the message.
|
boolean |
getRetain()
Get the retain value of the message.
|
boolean |
getRetainAsPublished()
Get the retained value as published.
|
String |
getStringProperty(String name)
Get a message property as a String.
|
Object |
getUserData()
Get a user object associated with this message.
|
boolean |
propertyExists(String name)
Return whether a property exists.
|
ImaMessage |
setBodyBytes(byte[] body)
Set the body as a byte array.
|
ImaMessage |
setBodyMap(Map<String,Object> body)
Set the body as a Map.
|
ImaMessage |
setBodyText(String body)
Set the body as a String.
|
ImaMessage |
setMessageType(ImaMessageType msgtype)
Set the message type.
|
ImaMessage |
setPersistent(boolean persist)
Set the persistence of the message.
|
ImaMessage |
setReliability(ImaReliability reliability)
Set the reliability of the message.
|
ImaMessage |
setRetain(boolean retain)
Set the retain value of the message.
|
void |
setUserData(Object userdata)
Set a user object associated with this message.
|
static final String COPYRIGHT
ImaMessage addProperties(Map<String,Object> props)
props
- The properties to addImaMessage clearProperties()
byte[] getBodyBytes()
Map<String,Object> getBodyMap()
ImaPluginException
- if the body cannot be converted to a map.String getBodyText()
ImaPlubinException
- if the body cannot be converted to a String.boolean getBooleanProperty(String name, boolean default_value)
name
- The name of the propertydefault_value
- The default if the property is missing or not a booleanString getDestination()
This is guaranteed to exist and be at least one character long. This is almost always the destination to which the message was originally published, but this depends on information provided by the originator.
ImaDestinationType getDestinationType()
ImaMessageType getMessageType()
This is the indication from the originator of the message of the physical format of the message body. It is possible that the message can be converted to another format, and it is possible that the message body is not validly of the specified format.
boolean getPersistence()
The persistence value of true means that the message continues to be available even if the server fails. This is commonly implemented by writing the message to non-volatile storage.
ImaReliability getReliability()
The reliability of a message deals with the message guarantee in case of client or network failure.
boolean getRetain()
When a message is received, the setting of the retain flag is based on whether the message was delivered as part of the creation of a subscription. If the subscription is already active when a retained message is sent, it will not be seen as retained to the existing subscriptions.
boolean getRetainAsPublished()
When a message is published, the retain flag indicates it should be retained and sent for any new subscriptions. This retain as published flag indicates whether retain was requested when the message was published. This can be used to set the retain flag when a message is forwarded.
Map<String,Object> getProperties()
Only named properties are returned. These are commonly the user properties. Many of the system properties are returned as other fields. The resulting map cannot be modified.
int getIntPropery(String name, int default_value)
If the message property is not an integer, attempt to convert it to an integer. If the property cannot be converted to an integer, return the default value.
name
- The name of the propertydefault_value
- The default value if the property is missing or cannot be converted to an integerObject getProperty(String name)
As it is valid for a property to have a null value, the method propertyExists() can be used to differentiate between an existing property with a null value and a missing property.
All properties can be converted to a String, but the resulting String might not be useful in all cases.
name
- The name of the propertyString getStringProperty(String name)
As it is valid for a property to have a null value, the method propertyExists() can be used to differentiate between an existing property with a null value and a missing property.
name
- The property nameObject getUserData()
boolean propertyExists(String name)
name
- The property nameImaMessage setMessageType(ImaMessageType msgtype)
msgtype
- The messge typeImaMessage setBodyBytes(byte[] body)
This completely replaces any existing body.
body
- The byte array to set as the bodyImaMessage setBodyMap(Map<String,Object> body)
This completely replaces any existing body.
body
- The byte array to set as the bodyImaMessage setBodyText(String body)
This completely replaces any existing body.
body
- The string to set as the body.ImaMessage setPersistent(boolean persist)
The persistence value of true means that the message continues to be available even if the server fails. This is commonly implemented by writing the message to non-volatile storage.
persist
- true for persistent and false for non-persistentImaMessage setReliability(ImaReliability reliability)
The reliability of a message deals with the message guarantee in case of client or network failure. To ensure message delivery in the case of a server failure the message should also be persistent.
reliability
- The reliabilityvoid setUserData(Object userdata)
userdata
- An object to associate with this messageImaMessage setRetain(boolean retain)
retain
- true if the message should be retained, false if it should not be retained.void acknowledge(int rc)
rc
- A return code, 0=good.void acknowledge(int rc, ImaTransaction transaction)
rc
- A return code, 0=good.Copyright © Contributors to the Eclipse Foundation 2014-2021