public abstract class AbstractMessage extends Object implements BasicMessage
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 |
AbstractMessage() |
| Modifier and Type | Method and Description |
|---|---|
protected static com.fasterxml.jackson.databind.ObjectMapper |
buildObjectMapperForDeserialization()
This is static, so really there is no true overriding it in subclasses.
|
protected com.fasterxml.jackson.databind.ObjectMapper |
buildObjectMapperForSerialization() |
static <T extends BasicMessage> |
fromJSON(InputStream in,
Class<T> clazz)
Convenience static method that reads a JSON string from the given stream and converts the JSON
string to a particular message object.
|
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 static <T extends BasicMessage> BasicMessageWithExtraData<T> fromJSON(InputStream in, Class<T> clazz)
BasicMessageWithExtraData.getBinaryData()) since it will handle this condition
properly.in - input stream that has a JSON string at the head.clazz - the class whose instance is represented by the JSON stringBinaryData object that you
can use to stream any additional data that came in the given input stream.protected static com.fasterxml.jackson.databind.ObjectMapper buildObjectMapperForDeserialization()
public String toJSON()
toJSON in interface BasicMessageprotected com.fasterxml.jackson.databind.ObjectMapper buildObjectMapperForSerialization()
public MessageId getMessageId()
getMessageId in interface BasicMessagepublic void setMessageId(MessageId messageId)
setMessageId in interface BasicMessagepublic MessageId getCorrelationId()
getCorrelationId in interface BasicMessagepublic void setCorrelationId(MessageId correlationId)
setCorrelationId in interface BasicMessagepublic Map<String,String> getHeaders()
null but may return an empty map.getHeaders in interface BasicMessagepublic void setHeaders(Map<String,String> headers)
getHeaders() will return an empty map.
Note that the header values are all expected to be strings.setHeaders in interface BasicMessageheaders - name/value propertiesCopyright © 2014–2017 Red Hat, Inc.. All rights reserved.