# AMQP support

The gateway serves AMQP 1.0. [Compatibility](/mq-gateway/0.4/reference/compatibility.md) lists the clients and test suites that we test the gateway with.

## Supported

| Feature                                      | Notes                                                                                                             |
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| TCP and TLS (`amqps`)                        | TLS comes from the `tls` settings                                                                                 |
| WebSocket                                    | On a listener with `ws-path`, subprotocol `amqp`                                                                  |
| SASL PLAIN and ANONYMOUS                     | The listener maps the credential to a NATS user                                                                   |
| SASL EXTERNAL                                | Only on a `cert` listener, where it is the only mechanism                                                         |
| Sessions and links                           | Up to 256 sessions per connection and 256 links per session                                                       |
| Heartbeats and idle time-out                 | The gateway closes a client that is silent for 60s                                                                |
| Send to an address                           | The address is a NATS subject without wildcards                                                                   |
| Anonymous relay                              | The `to` of each message names its subject                                                                        |
| Presettled delivery                          | Core NATS                                                                                                         |
| Unsettled delivery                           | Only to addresses that a binding stores                                                                           |
| Receive from an address                      | The source can use the `*` and `>` wildcards                                                                      |
| Queues (move mode)                           | The default on a stored address                                                                                   |
| Copy mode and the `topic` capability         | Each link gets its own consumer                                                                                   |
| Queue browsing, such as a JMS `QueueBrowser` | The browser removes no messages                                                                                   |
| Operator queues                              | Use the source `<address>::<queue>`                                                                               |
| JMS selectors                                | `apache.org:selector-filter:string` or `amqp:sql-filter`. See [Selectors](/mq-gateway/0.4/reference/selectors.md) |
| Routes                                       | `amqp.routes` puts application properties in the subject                                                          |
| Outcomes                                     | `accepted`, `rejected`, `released` and `modified`. See Things to know                                             |
| Delivery count                               | Counts only failed attempts, with `amqp.delivery-counts`                                                          |
| Credit, drain and echo                       |                                                                                                                   |
| Request/reply and JMS temporary destinations | Dynamic sources and targets give reply addresses                                                                  |
| `ttl` and `absolute-expiry-time`             | The gateway does not deliver an expired message                                                                   |
| Message fidelity                             | An AMQP receiver gets the sections that the sender sent                                                           |
| Message size                                 | Up to the NATS server's `max_payload`                                                                             |

## Not supported

* Transactions. The gateway refuses the coordinator with `amqp:not-implemented`.
* Shared subscriptions, and durable subscriptions other than the address's queue
* Link recovery and resumed deliveries
* `rcv-settle-mode` second. The gateway answers with first.
* Filters other than selectors, such as `no-local`
* More than one selector on a link, and a selector on `JMSXDeliveryCount`
* Dead-letter addresses
* Priority, scheduled delivery and message groups. The gateway carries these fields but does not act on them.
* `modified` with `message-annotations`
* Management nodes (`$management`) and claims-based security (`$cbs`)
* SASL mechanisms other than PLAIN, ANONYMOUS and EXTERNAL
* Copy mode, and selectors that the gateway evaluates, on a work-queue stream

## Things to know

* **Settlement decides storage.** An unsettled send to an address that no binding stores is rejected with `amqp:not-allowed`. The gateway does not change it to a presettled send. A JMS persistent send to a temporary queue is refused for the same reason.
* **Receivers on an address share a queue.** By default, every receiver on a stored address, on every gateway, reads one durable consumer, so each message goes to one receiver. A queue that no link uses for `amqp.queue-inactive` (1h) is removed. A new queue starts from the first message the stream holds on the address.
* **Outcomes decide redelivery.** `accepted` and `rejected` end the message, so the gateway never delivers it again. `released` returns it to the queue. `modified` also returns it, and with `delivery-failed` it counts as a failed attempt. With `undeliverable-here`, only other receivers get it again.
* **A selector can have its own queue.** A queue is named by the subjects it reads and by the part of its selector that the gateway evaluates. A message that one queue's receiver accepts is still delivered to the address's other queues. On a routed address, a selector that the subject alone answers, such as `region = 'EU'` on `orders.{region}`, shares the queue of a receiver on `orders.EU`.
* **Duplicates after a failure.** When a link or connection ends, its unsettled deliveries go back to the queue and are delivered again. A delivery left unsettled for `amqp.ack-wait` (30s) is also sent again. A client that must not process a message twice should discard duplicates.
* **Send bodies as one `data` section.** MQTT and NATS clients get any other body, such as the `amqp-value` that Qpid JMS uses for a `TextMessage`, in its AMQP encoding.
* **Addresses are subjects.** The address `orders.eu` is the NATS subject `orders.eu`, which the MQTT topic `orders/eu` also reaches. See [Mapping to NATS](/mq-gateway/0.4/reference/mapping-to-nats.md).
