Class MessageEnvelop
java.lang.Object
org.pipservices3.messaging.queues.MessageEnvelope
public class MessageEnvelop extends Object
Allows adding additional information to messages. A correlation id, message id, and a message type
are added to the data being sent/received. Additionally, a MessageEnvelope can reference a lock token.
Side note: a MessageEnvelope's message is stored as a buffer, so strings are converted using utf8 conversions.
-
Constructor Summary
Constructors Constructor Description MessageEnvelop()
Creates a new MessageEnvelope.MessageEnvelop(String correlationId, String messageType, Object message)
Creates a new MessageEnvelop, which adds a correlation id, message id, and a type to the data being sent/received.MessageEnvelop(String correlationId, String messageType, String message)
Creates a new MessageEnvelop, which adds a correlation id, message id, and a type to the data being sent/received. -
Method Summary
Modifier and Type Method Description String
getCorrelationId()
Object
getMessage()
<T> T
getMessageAsJson(Class<T> type)
String
getMessageId()
String
getMessageType()
Object
getReference()
ZonedDateTime
getSentTime()
void
setCorrelationId(String value)
void
setMessage(Object value)
void
setMessageAsJson(Object message)
Stores the given string.void
setMessageId(String value)
void
setMessageType(String value)
void
setReference(Object value)
Sets a lock token reference for this MessageEnvelope.void
setSentTime(ZonedDateTime value)
String
toString()
Convert's this MessageEnvelope to a string, using the following format:"[correlation_id, message_type, message.toString]"
.
-
Constructor Details
-
MessageEnvelop
public MessageEnvelop()Creates a new MessageEnvelope. -
MessageEnvelop
Creates a new MessageEnvelop, which adds a correlation id, message id, and a type to the data being sent/received.- Parameters:
correlationId
- (optional) transaction id to trace execution through call chain.messageType
- a string value that defines the message's type.message
- the data being sent/received.
-
MessageEnvelop
Creates a new MessageEnvelop, which adds a correlation id, message id, and a type to the data being sent/received.- Parameters:
correlationId
- (optional) transaction id to trace execution through call chain.messageType
- a string value that defines the message's type.message
- the data being sent/received.
-
-
Method Details
-
getReference
- Returns:
- the lock token that this MessageEnvelope references.
-
setReference
Sets a lock token reference for this MessageEnvelope.- Parameters:
value
- the lock token to reference.
-
getCorrelationId
-
setCorrelationId
-
getMessageId
-
setMessageId
-
getMessageType
-
setMessageType
-
getSentTime
-
setSentTime
-
getMessage
-
setMessage
-
setMessageAsJson
public void setMessageAsJson(Object message) throws com.fasterxml.jackson.core.JsonProcessingExceptionStores the given string.- Parameters:
message
- the string to set. Will be converted to a buffer, using UTF-8 encoding.- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getMessageAsJson
public <T> T getMessageAsJson(Class<T> type) throws com.fasterxml.jackson.databind.JsonMappingException, com.fasterxml.jackson.core.JsonParseException, IOException- Returns:
- the value that was stored in this message as a JSON string.
- Throws:
com.fasterxml.jackson.databind.JsonMappingException
com.fasterxml.jackson.core.JsonParseException
IOException
-
toString
Convert's this MessageEnvelope to a string, using the following format:"[correlation_id, message_type, message.toString]"
. If any of the values arenull
, they will be replaced with---
.
-