# file: channel.aus

## class: RabbitMqChannel

[33:14] (extern: com.lehman.aussom.RabbitMqChannel) **extends: object** 

A RabbitMQ channel: the heart of the AMQP 0-9-1 API. Exchange and
queue operations, bindings, publishing, pull consumption,
acknowledgements, QoS, publisher confirms, and transactions all
happen on a channel. Open one with connection.openChannel().
Channels are not thread safe. Use each channel from one thread
only - the same rule as the underlying client. Messages are routed
by publishing to an exchange with a routing key; bindings decide
which queues receive them. There are no broker-side selectors -
routing keys and bindings do that job.

#### Methods

- **RabbitMqChannel** ()


- **exchangeDeclare** (`string Name, string Type = "direct", bool Durable = false, bool AutoDelete = false, bool Internal = false, map Args = null`)

	> Declares an exchange.

	- **@p** `Name` is a string with the exchange name.
	- **@p** `Type` is a string with direct, fanout, topic, or headers (default direct).
	- **@p** `Durable` is a bool with true to survive broker restart (default false).
	- **@p** `AutoDelete` is a bool with true to delete when unused (default false).
	- **@p** `Internal` is a bool with true to refuse direct publishes (default false).
	- **@p** `Args` is a map with exchange arguments (optional).
	- **@r** `this` object


- **exchangeDeclarePassive** (`string Name`)

	> Checks that an exchange exists. Errors when it does not.

	- **@p** `Name` is a string with the exchange name.
	- **@r** `this` object


- **exchangeDelete** (`string Name, bool IfUnused = false`)

	> Deletes an exchange.

	- **@p** `Name` is a string with the exchange name.
	- **@p** `IfUnused` is a bool with true to only delete when unused (default false).
	- **@r** `this` object


- **exchangeBind** (`string Destination, string Source, string RoutingKey, map Args = null`)

	> Binds one exchange to another, so messages routed to Source flow on to Destination.

	- **@p** `Destination` is a string with the destination exchange.
	- **@p** `Source` is a string with the source exchange.
	- **@p** `RoutingKey` is a string with the binding key.
	- **@p** `Args` is a map with binding arguments (optional).
	- **@r** `this` object


- **exchangeUnbind** (`string Destination, string Source, string RoutingKey, map Args = null`)

	> Removes an exchange-to-exchange binding.

	- **@p** `Destination` is a string with the destination exchange.
	- **@p** `Source` is a string with the source exchange.
	- **@p** `RoutingKey` is a string with the binding key.
	- **@p** `Args` is a map with binding arguments (optional).
	- **@r** `this` object


- **queueDeclare** (`string Name = "", bool Durable = false, bool Exclusive = false, bool AutoDelete = false, map Args = null`)

	> Declares a queue and returns its name. An empty name asks the broker for a server-named exclusive auto-delete queue (the standard reply-queue idiom). The Args map carries every x- feature: x-message-ttl, x-expires, x-max-length, x-dead-letter-exchange, x-dead-letter-routing-key, x-max-priority, x-queue-type (classic/quorum/stream), and x-single-active-consumer. RabbitMQ 4.2+ denies transient (non-durable) non-exclusive queues by default, so declare named queues durable unless they are exclusive.

	- **@p** `Name` is a string with the queue name (default "" for server-named).
	- **@p** `Durable` is a bool with true to survive broker restart (default false).
	- **@p** `Exclusive` is a bool with true to scope the queue to this connection (default false).
	- **@p** `AutoDelete` is a bool with true to delete when the last consumer goes away (default false).
	- **@p** `Args` is a map with queue arguments (optional).
	- **@r** `A` string with the queue name.


- **queueDeclarePassive** (`string Name`)

	> Checks that a queue exists. Errors when it does not.

	- **@p** `Name` is a string with the queue name.
	- **@r** `A` map with queue, messageCount, and consumerCount.


- **queueDelete** (`string Name, bool IfUnused = false, bool IfEmpty = false`)

	> Deletes a queue.

	- **@p** `Name` is a string with the queue name.
	- **@p** `IfUnused` is a bool with true to only delete without consumers (default false).
	- **@p** `IfEmpty` is a bool with true to only delete when empty (default false).
	- **@r** `An` int with the count of messages deleted with the queue.


- **queuePurge** (`string Name`)

	> Removes all ready messages from a queue.

	- **@p** `Name` is a string with the queue name.
	- **@r** `An` int with the count of messages removed.


- **queueBind** (`string Queue, string Exchange, string RoutingKey, map Args = null`)

	> Binds a queue to an exchange with a routing key.

	- **@p** `Queue` is a string with the queue name.
	- **@p** `Exchange` is a string with the exchange name.
	- **@p** `RoutingKey` is a string with the binding key (topic exchanges match * for one word and # for zero or more).
	- **@p** `Args` is a map with binding arguments - headers exchanges take the match table here, including x-match all/any (optional).
	- **@r** `this` object


- **queueUnbind** (`string Queue, string Exchange, string RoutingKey, map Args = null`)

	> Removes a queue-to-exchange binding.

	- **@p** `Queue` is a string with the queue name.
	- **@p** `Exchange` is a string with the exchange name.
	- **@p** `RoutingKey` is a string with the binding key.
	- **@p** `Args` is a map with binding arguments (optional).
	- **@r** `this` object


- **messageCount** (`string Queue`)

	> Counts the ready messages on a queue.

	- **@p** `Queue` is a string with the queue name.
	- **@r** `An` int with the message count.


- **consumerCount** (`string Queue`)

	> Counts the consumers on a queue.

	- **@p** `Queue` is a string with the queue name.
	- **@r** `An` int with the consumer count.


- **publish** (`string Exchange, string RoutingKey, Msg, bool Mandatory = false`)

	> Publishes a message. The message is a RabbitMqMessage object, a plain string (text body with no properties), or a map in the message-map shape (body, persistent, correlationId, headers, and so on). An empty exchange name is the default exchange: the routing key is then the destination queue name. Mandatory publishes that no queue could route come back through pollReturned().

	- **@p** `Exchange` is a string with the exchange name ("" for the default exchange).
	- **@p** `RoutingKey` is a string with the routing key.
	- **@p** `Msg` is the message (RabbitMqMessage, string, or map).
	- **@p** `Mandatory` is a bool with true to return unroutable messages (default false).
	- **@r** `this` object


- **pollReturned** (`int TimeoutMs = 0`)

	> Drains one returned (unroutable mandatory) message.

	- **@p** `TimeoutMs` is an int with how long to wait (default 0 = no wait).
	- **@r** `A` RabbitMqMessage object, or null when none is pending.


- **get** (`string Queue, bool AutoAck = true`)

	> Pulls one message from a queue without a consumer.

	- **@p** `Queue` is a string with the queue name.
	- **@p** `AutoAck` is a bool with true to acknowledge on delivery (default true). With false, ack through the message or this channel.
	- **@r** `A` RabbitMqMessage object, or null when the queue is empty.


- **ack** (`int DeliveryTag, bool Multiple = false`)

	> Acknowledges a delivery by tag.

	- **@p** `DeliveryTag` is an int with the delivery tag.
	- **@p** `Multiple` is a bool with true to acknowledge everything up to and including the tag (default false).
	- **@r** `this` object


- **nack** (`int DeliveryTag, bool Requeue = true, bool Multiple = false`)

	> Negatively acknowledges a delivery by tag.

	- **@p** `DeliveryTag` is an int with the delivery tag.
	- **@p** `Requeue` is a bool with true to put the message back on the queue, false to drop or dead-letter it (default true).
	- **@p** `Multiple` is a bool with true to nack everything up to and including the tag (default false).
	- **@r** `this` object


- **reject** (`int DeliveryTag, bool Requeue = true`)

	> Rejects a delivery by tag.

	- **@p** `DeliveryTag` is an int with the delivery tag.
	- **@p** `Requeue` is a bool with true to put the message back on the queue (default true).
	- **@r** `this` object


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

	> Asks the broker to redeliver this channel's unacknowledged messages.

	- **@p** `Requeue` is a bool with true to allow delivery to other consumers (default true).
	- **@r** `this` object


- **qos** (`int PrefetchCount, bool Global = false`)

	> Sets the prefetch window: how many unacknowledged messages the broker sends before waiting for acks. The back-pressure knob for manual-ack consumers.

	- **@p** `PrefetchCount` is an int with the window size.
	- **@p** `Global` is a bool with true to share the window across the channel's consumers (default false).
	- **@r** `this` object


- **confirmSelect** ()

	> Puts this channel in publisher-confirm mode, so the broker acknowledges publishes. Mutually exclusive with transactions.

	- **@r** `this` object


- **getNextPublishSeqNo** ()

	> Gets the sequence number the next publish will get, for correlating confirms.

	- **@r** `An` int with the next publish sequence number.


- **waitForConfirms** (`int TimeoutMs = 0`)

	> Waits until every publish since confirmSelect() was confirmed.

	- **@p** `TimeoutMs` is an int with how long to wait (default 0 = forever).
	- **@r** `A` bool with true when all confirmed, false when the broker nacked any.


- **waitForConfirmsOrDie** (`int TimeoutMs = 0`)

	> Like waitForConfirms() but errors on a broker nack or timeout.

	- **@p** `TimeoutMs` is an int with how long to wait (default 0 = forever).
	- **@r** `this` object


- **txSelect** ()

	> Puts this channel in transaction mode: publishes and acks batch until txCommit() or txRollback(). Mutually exclusive with publisher confirms.

	- **@r** `this` object


- **txCommit** ()

	> Commits the open transaction.

	- **@r** `this` object


- **txRollback** ()

	> Rolls the open transaction back, discarding batched publishes and acks.

	- **@r** `this` object


- **consume** (`string Queue, bool AutoAck = false, string ConsumerTag = "", bool Exclusive = false, map Args = null`)

	> Starts a push consumer on a queue. With AutoAck false (the default), call qos() first so the prefetch window bounds the in-flight messages.

	- **@p** `Queue` is a string with the queue name.
	- **@p** `AutoAck` is a bool with true to acknowledge on delivery (default false).
	- **@p** `ConsumerTag` is a string with the consumer tag (default "" for broker-assigned).
	- **@p** `Exclusive` is a bool with true for an exclusive consumer (default false).
	- **@p** `Args` is a map with consumer arguments such as x-priority (optional).
	- **@r** `A` new RabbitMqConsumer object.


- **isOpen** ()

	> Reports whether the channel is open. Protocol errors (for example acking an unknown tag) close the channel.

	- **@r** `A` bool with true while open.


- **getChannelNumber** ()

	> Gets this channel's number on its connection.

	- **@r** `An` int with the channel number.


- **close** ()

	> Closes the channel. Safe to call more than once.

	- **@r** `this` object




