class: RabbitMqMessage
[44:14] (extern: com.lehman.aussom.RabbitMqMessage) extends: object
A RabbitMQ message, in both directions. Outgoing: construct (with an optional message map), set the body and properties, publish through a channel. Incoming: returned by get()/receive() and the listener, carrying the envelope (exchange, routing key, delivery tag, redeliver flag) plus ack convenience backed by the channel it arrived on. The message-map shape used by the constructor, fromMap(), toMap(), and channel.publish() (every key optional): { "body": "text" | buffer, "contentType": "application/json", "contentEncoding": "utf-8", "persistent": true, // or "deliveryMode": 1|2 "priority": 5, "correlationId": "abc", "replyTo": "q.replies", "expiration": "60000", "messageId": "m-1", "timestamp": 1780000000000, "type": "order", "userId": "orders", "appId": "shop", "headers": { ... } // nested map, deep-converted } Bodies are plain bytes: there is no typed message hierarchy and no object deserialization surface.
Methods
-
RabbitMqMessage (
map MsgMap = null)Creates a message, optionally populated from a message map.
- @p
MsgMapis a map in the message-map shape (optional).
- @p
-
newMessage (
map MsgMap = null) -
setBody (
string Text)Sets the body from a UTF-8 string.
- @p
Textis a string with the body. - @r
thisobject
- @p
-
getBody ()
Gets the body as a UTF-8 string.
- @r
Astring with the body.
- @r
-
setBodyBuffer (
object Buff)Sets the body from a Buffer's bytes. Size the Buffer to the exact payload length - the whole backing array is sent.
- @p
Buffis a Buffer object with the body bytes. - @r
thisobject
- @p
-
getBodyBuffer ()
Gets the body as a Buffer object.
- @r
ABuffer object with the body bytes.
- @r
-
setContentType (
string Type)Sets the content type, for example application/json.
- @p
Typeis a string with the content type. - @r
thisobject
- @p
-
getContentType ()
Gets the content type.
- @r
Astring with the content type, or null when unset.
- @r
-
setContentEncoding (
string Encoding)Sets the content encoding, for example utf-8.
- @p
Encodingis a string with the content encoding. - @r
thisobject
- @p
-
getContentEncoding ()
Gets the content encoding.
- @r
Astring with the content encoding, or null when unset.
- @r
-
setDeliveryMode (
int Mode)Sets the delivery mode: 1 transient, 2 persistent. Persistent messages on durable queues survive broker restart.
- @p
Modeis an int with 1 or 2. - @r
thisobject
- @p
-
getDeliveryMode ()
Gets the delivery mode.
- @r
Anint with 1 or 2, or null when unset.
- @r
-
setPersistent (
bool On)Sugar for setDeliveryMode: true is persistent (2), false is transient (1).
- @p
Onis a bool with true for persistent. - @r
thisobject
- @p
-
isPersistent ()
Reports whether the delivery mode is persistent.
- @r
Abool with true when persistent.
- @r
-
setPriority (
int Priority)Sets the priority. Takes effect on classic queues declared with x-max-priority.
- @p
Priorityis an int with the priority (0-9 typical). - @r
thisobject
- @p
-
getPriority ()
Gets the priority.
- @r
Anint with the priority, or null when unset.
- @r
-
setCorrelationId (
string Id)Sets the correlation ID used to match replies to requests.
- @p
Idis a string with the correlation ID. - @r
thisobject
- @p
-
getCorrelationId ()
Gets the correlation ID.
- @r
Astring with the correlation ID, or null when unset.
- @r
-
setReplyTo (
string Queue)Sets the reply-to queue name for request/reply. The built-in pseudo-queue amq.rabbitmq.reply-to gives fast RPC with no queue churn.
- @p
Queueis a string with the reply queue name. - @r
thisobject
- @p
-
getReplyTo ()
Gets the reply-to queue name.
- @r
Astring with the reply queue, or null when unset.
- @r
-
setExpiration (
string Ms)Sets the per-message TTL. Per the AMQP spec the value is a string holding milliseconds, for example "60000".
- @p
Msis a string with the TTL in milliseconds. - @r
thisobject
- @p
-
getExpiration ()
Gets the per-message TTL string.
- @r
Astring with the TTL, or null when unset.
- @r
-
setMessageId (
string Id)Sets the application message ID.
- @p
Idis a string with the message ID. - @r
thisobject
- @p
-
getMessageId ()
Gets the application message ID.
- @r
Astring with the message ID, or null when unset.
- @r
-
setTimestamp (
int EpochMs)Sets the timestamp. The AMQP wire format keeps one-second precision, so milliseconds round down in transit.
- @p
EpochMsis an int with epoch milliseconds. - @r
thisobject
- @p
-
getTimestamp ()
Gets the timestamp.
- @r
Anint with epoch milliseconds, or null when unset.
- @r
-
setType (
string Type)Sets the application message type name.
- @p
Typeis a string with the type name. - @r
thisobject
- @p
-
getType ()
Gets the application message type name.
- @r
Astring with the type name, or null when unset.
- @r
-
setUserId (
string Id)Sets the user ID. RabbitMQ validates it against the publishing connection's user.
- @p
Idis a string with the user ID. - @r
thisobject
- @p
-
getUserId ()
Gets the user ID.
- @r
Astring with the user ID, or null when unset.
- @r
-
setAppId (
string Id)Sets the application ID.
- @p
Idis a string with the application ID. - @r
thisobject
- @p
-
getAppId ()
Gets the application ID.
- @r
Astring with the application ID, or null when unset.
- @r
-
setHeader (
string Name, Value)Sets one header value.
- @p
Nameis a string with the header name. - @p
Valueis the header value (string/int/double/bool/list/map). - @r
thisobject
- @p
-
getHeader (
string Name)Gets one header value as a native Aussom value.
- @p
Nameis a string with the header name. - @r
Theheader value, or null when absent.
- @p
-
setHeaders (
map Headers)Replaces all headers from a native map. Values convert deeply.
- @p
Headersis a map with the headers. - @r
thisobject
- @p
-
getHeaders ()
Gets all headers as a native map. Values convert deeply, so nested lists and maps come back as Aussom lists and maps.
- @r
Amap with the headers.
- @r
-
hasHeader (
string Name)Reports whether the named header is present.
- @p
Nameis a string with the header name. - @r
Abool with true when present.
- @p
-
fromMap (
map M)Populates body, properties, and headers from one map in the message-map shape. Unknown keys error so typos surface.
- @p
Mis a map in the message-map shape. - @r
thisobject
- @p
-
setProperties (
map P)Sets the AMQP properties (plus nested headers) from one map. The body key is rejected here - use fromMap() or setBody().
- @p
Pis a map with the properties. - @r
thisobject
- @p
-
getProperties ()
Gets the set AMQP properties (plus headers) as one native map. Unset properties are omitted.
- @r
Amap with the properties.
- @r
-
toMap ()
Dumps the entire message - body, properties, headers, and (for incoming messages) exchange, routingKey, deliveryTag, and redeliver - to one native map, ready to log or feed to a JSON encoder.
- @r
Amap with the whole message.
- @r
-
getDeliveryTag ()
Gets the broker delivery tag of an incoming message.
- @r
Anint with the delivery tag, or null on an outgoing message.
- @r
-
getExchange ()
Gets the exchange an incoming message arrived through.
- @r
Astring with the exchange name, or null.
- @r
-
getRoutingKey ()
Gets the routing key an incoming message arrived with.
- @r
Astring with the routing key, or null.
- @r
-
isRedeliver ()
Reports whether the broker marked this delivery as redelivered (it was requeued or recovered before).
- @r
Abool with true when redelivered.
- @r
-
getConsumerTag ()
Gets the consumer tag that received this message.
- @r
Astring with the consumer tag, or null.
- @r
-
ack ()
Acknowledges this incoming message on the channel it arrived on.
- @r
thisobject
- @r
-
nack (
bool Requeue = true)Negatively acknowledges this incoming message.
- @p
Requeueis a bool with true to put it back on the queue, false to drop or dead-letter it (default true). - @r
thisobject
- @p
-
reject (
bool Requeue = true)Rejects this incoming message.
- @p
Requeueis a bool with true to put it back on the queue (default true). - @r
thisobject
- @p