pip_services3_messaging.queues.MessageEnvelope module

class pip_services3_messaging.queues.MessageEnvelope.MessageEnvelope(correlation_id: Optional[str], message_type: Optional[str], message: Optional[Any])

Bases: 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.

static from_json(value: str) → Optional[pip_services3_messaging.queues.MessageEnvelope.MessageEnvelope]

Converts a JSON string into a MessageEnvelope The message payload is passed as base64 string

Parameters

value – a JSON encoded string

Returns

a decoded Message Envelop.

get_message_as() → Any

TODO add description

Returns

the value that was stored in this message as a JSON string.

get_message_as_string() → Optional[str]

TODO add description

Returns

the information stored in this message as a UTF-8 encoded string.

get_reference() → Any

Gets a lock token reference for this MessageEnvelope.

Returns

the lock token that this MessageEnvelope references.

set_message_as_object(value: Any)

Stores the given value as a object.

Parameters

value – the value to convert to JSON and store in this message.

set_message_as_string(value: str)

Stores the given string.

Parameters

value – the string to set. Will be converted to a buffer, using UTF-8 encoding.

set_reference(value: Any)

Sets a lock token reference for this MessageEnvelope.

Parameters

value – the lock token to reference.

to_json()dict

Converts this MessageEnvelope to a JSON string. The message payload is passed as base64 string

Returns

A JSON encoded representation is this object.

to_string()str

Convert’s this MessageEnvelope to a string, using the following format: `"[<correlation_id>,<message_type>,<message.toString>]"`.

If any of the values are `None`, they will be replaced with `---`.

Returns

the generated string.