public abstract class BasicMessage extends Object
message ID is assigned by the messaging framework and so typically is not explicitly set.
The correlation ID is a message ID of another message that was sent previously. This is
usually left unset unless this message needs to be correlated with another. As an example, when a process is stopped,
you can correlate the "Stopped" event with the "Stopping" event so you can later determine how long it took for the
process to stop.
The headers are normally those out-of-band properties that are sent with the message.| Modifier | Constructor and Description |
|---|---|
protected |
BasicMessage() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends BasicMessage> |
fromJSON(String json,
Class<T> clazz)
Convenience static method that converts a JSON string to a particular message object.
|
MessageId |
getCorrelationId()
If this message is correlated with another message, this will be that other message's ID.
|
Map<String,String> |
getHeaders()
The headers that were shipped along side of the message when the message was received.
|
MessageId |
getMessageId()
Returns the message ID that was assigned to this message by the messaging infrastructure.
|
void |
setCorrelationId(MessageId correlationId) |
void |
setHeaders(Map<String,String> headers)
Sets headers that will be sent with the message when the message gets delivered.
|
void |
setMessageId(MessageId messageId) |
String |
toJSON()
Converts this message to its JSON string representation.
|
String |
toString() |
public static <T extends BasicMessage> T fromJSON(String json, Class<T> clazz)
json - the JSON stringclazz - the class whose instance is represented by the JSON stringpublic String toJSON()
public MessageId getMessageId()
public void setMessageId(MessageId messageId)
public MessageId getCorrelationId()
public void setCorrelationId(MessageId correlationId)
public Map<String,String> getHeaders()
null but may return an empty map.public void setHeaders(Map<String,String> headers)
getHeaders() will return an empty map.
Note that the header values are all expected to be strings.headers - name/value propertiesCopyright © 2015 Red Hat, Inc.. All rights reserved.