# file: message.aus

## 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** `MsgMap` is a map in the message-map shape (optional).


- **newMessage** (`map MsgMap = null`)


- **setBody** (`string Text`)

	> Sets the body from a UTF-8 string.

	- **@p** `Text` is a string with the body.
	- **@r** `this` object


- **getBody** ()

	> Gets the body as a UTF-8 string.

	- **@r** `A` string with the body.


- **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** `Buff` is a Buffer object with the body bytes.
	- **@r** `this` object


- **getBodyBuffer** ()

	> Gets the body as a Buffer object.

	- **@r** `A` Buffer object with the body bytes.


- **setContentType** (`string Type`)

	> Sets the content type, for example application/json.

	- **@p** `Type` is a string with the content type.
	- **@r** `this` object


- **getContentType** ()

	> Gets the content type.

	- **@r** `A` string with the content type, or null when unset.


- **setContentEncoding** (`string Encoding`)

	> Sets the content encoding, for example utf-8.

	- **@p** `Encoding` is a string with the content encoding.
	- **@r** `this` object


- **getContentEncoding** ()

	> Gets the content encoding.

	- **@r** `A` string with the content encoding, or null when unset.


- **setDeliveryMode** (`int Mode`)

	> Sets the delivery mode: 1 transient, 2 persistent. Persistent messages on durable queues survive broker restart.

	- **@p** `Mode` is an int with 1 or 2.
	- **@r** `this` object


- **getDeliveryMode** ()

	> Gets the delivery mode.

	- **@r** `An` int with 1 or 2, or null when unset.


- **setPersistent** (`bool On`)

	> Sugar for setDeliveryMode: true is persistent (2), false is transient (1).

	- **@p** `On` is a bool with true for persistent.
	- **@r** `this` object


- **isPersistent** ()

	> Reports whether the delivery mode is persistent.

	- **@r** `A` bool with true when persistent.


- **setPriority** (`int Priority`)

	> Sets the priority. Takes effect on classic queues declared with x-max-priority.

	- **@p** `Priority` is an int with the priority (0-9 typical).
	- **@r** `this` object


- **getPriority** ()

	> Gets the priority.

	- **@r** `An` int with the priority, or null when unset.


- **setCorrelationId** (`string Id`)

	> Sets the correlation ID used to match replies to requests.

	- **@p** `Id` is a string with the correlation ID.
	- **@r** `this` object


- **getCorrelationId** ()

	> Gets the correlation ID.

	- **@r** `A` string with the correlation ID, or null when unset.


- **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** `Queue` is a string with the reply queue name.
	- **@r** `this` object


- **getReplyTo** ()

	> Gets the reply-to queue name.

	- **@r** `A` string with the reply queue, or null when unset.


- **setExpiration** (`string Ms`)

	> Sets the per-message TTL. Per the AMQP spec the value is a string holding milliseconds, for example "60000".

	- **@p** `Ms` is a string with the TTL in milliseconds.
	- **@r** `this` object


- **getExpiration** ()

	> Gets the per-message TTL string.

	- **@r** `A` string with the TTL, or null when unset.


- **setMessageId** (`string Id`)

	> Sets the application message ID.

	- **@p** `Id` is a string with the message ID.
	- **@r** `this` object


- **getMessageId** ()

	> Gets the application message ID.

	- **@r** `A` string with the message ID, or null when unset.


- **setTimestamp** (`int EpochMs`)

	> Sets the timestamp. The AMQP wire format keeps one-second precision, so milliseconds round down in transit.

	- **@p** `EpochMs` is an int with epoch milliseconds.
	- **@r** `this` object


- **getTimestamp** ()

	> Gets the timestamp.

	- **@r** `An` int with epoch milliseconds, or null when unset.


- **setType** (`string Type`)

	> Sets the application message type name.

	- **@p** `Type` is a string with the type name.
	- **@r** `this` object


- **getType** ()

	> Gets the application message type name.

	- **@r** `A` string with the type name, or null when unset.


- **setUserId** (`string Id`)

	> Sets the user ID. RabbitMQ validates it against the publishing connection's user.

	- **@p** `Id` is a string with the user ID.
	- **@r** `this` object


- **getUserId** ()

	> Gets the user ID.

	- **@r** `A` string with the user ID, or null when unset.


- **setAppId** (`string Id`)

	> Sets the application ID.

	- **@p** `Id` is a string with the application ID.
	- **@r** `this` object


- **getAppId** ()

	> Gets the application ID.

	- **@r** `A` string with the application ID, or null when unset.


- **setHeader** (`string Name, Value`)

	> Sets one header value.

	- **@p** `Name` is a string with the header name.
	- **@p** `Value` is the header value (string/int/double/bool/list/map).
	- **@r** `this` object


- **getHeader** (`string Name`)

	> Gets one header value as a native Aussom value.

	- **@p** `Name` is a string with the header name.
	- **@r** `The` header value, or null when absent.


- **setHeaders** (`map Headers`)

	> Replaces all headers from a native map. Values convert deeply.

	- **@p** `Headers` is a map with the headers.
	- **@r** `this` object


- **getHeaders** ()

	> Gets all headers as a native map. Values convert deeply, so nested lists and maps come back as Aussom lists and maps.

	- **@r** `A` map with the headers.


- **hasHeader** (`string Name`)

	> Reports whether the named header is present.

	- **@p** `Name` is a string with the header name.
	- **@r** `A` bool with true when present.


- **fromMap** (`map M`)

	> Populates body, properties, and headers from one map in the message-map shape. Unknown keys error so typos surface.

	- **@p** `M` is a map in the message-map shape.
	- **@r** `this` object


- **setProperties** (`map P`)

	> Sets the AMQP properties (plus nested headers) from one map. The body key is rejected here - use fromMap() or setBody().

	- **@p** `P` is a map with the properties.
	- **@r** `this` object


- **getProperties** ()

	> Gets the set AMQP properties (plus headers) as one native map. Unset properties are omitted.

	- **@r** `A` map with the properties.


- **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** `A` map with the whole message.


- **getDeliveryTag** ()

	> Gets the broker delivery tag of an incoming message.

	- **@r** `An` int with the delivery tag, or null on an outgoing message.


- **getExchange** ()

	> Gets the exchange an incoming message arrived through.

	- **@r** `A` string with the exchange name, or null.


- **getRoutingKey** ()

	> Gets the routing key an incoming message arrived with.

	- **@r** `A` string with the routing key, or null.


- **isRedeliver** ()

	> Reports whether the broker marked this delivery as redelivered (it was requeued or recovered before).

	- **@r** `A` bool with true when redelivered.


- **getConsumerTag** ()

	> Gets the consumer tag that received this message.

	- **@r** `A` string with the consumer tag, or null.


- **ack** ()

	> Acknowledges this incoming message on the channel it arrived on.

	- **@r** `this` object


- **nack** (`bool Requeue = true`)

	> Negatively acknowledges this incoming message.

	- **@p** `Requeue` is a bool with true to put it back on the queue, false to drop or dead-letter it (default true).
	- **@r** `this` object


- **reject** (`bool Requeue = true`)

	> Rejects this incoming message.

	- **@p** `Requeue` is a bool with true to put it back on the queue (default true).
	- **@r** `this` object




