Skip to main content

Overview

MQ Gateway connects MQTT 3.1.1, MQTT 5.0 and AMQP 1.0 clients to NATS. Devices, PLCs and AMQP applications keep their protocol and their client libraries. Behind the gateway, every message is a NATS message, so these clients exchange messages with NATS services and with each other.

The gateway is not a broker. NATS routes the messages, applies the permissions and stores what must be kept. The gateway keeps nothing of its own, so you can run as many gateways as you need.

Why use it​

  • Bring existing clients to NATS. MQTT devices and AMQP or JMS applications connect without a code change.
  • One system to run. Storage, security and clustering come from the NATS system you already operate, not from a second broker.
  • One set of subjects. An MQTT topic, an AMQP address and a NATS subject name the same messages.
  • Storage only where you ask for it. QoS 0 and presettled AMQP messages travel over core NATS. QoS 1 and 2 and unsettled AMQP messages go to the streams that you bind.

Concepts​

TermWhat it is
SubjectThe NATS name of a message, such as plant1.line1.temp. The MQTT topic plant1/line1/temp and the AMQP address plant1.line1.temp are this subject.
StreamA JetStream stream. It stores messages, as a durable queue does in a broker.
BindingA config entry that stores a set of subjects in a stream. MQTT QoS 1 and 2 and unsettled AMQP need one.
BucketA JetStream KV bucket. MQTT retained messages, MQTT sessions and AMQP delivery counts each live in a bucket that you name.
ListenerA port that the gateway serves MQTT or AMQP on. Its auth mode decides which NATS user a client acts as.
NATS userThe identity that a client acts as. NATS applies that user's permissions to everything the client does.

You create the streams and buckets. The gateway never creates, changes or deletes them.

Where to start​

  1. Getting started: run the playground and pass messages between MQTT, AMQP and NATS clients.
  2. Durable messaging: store QoS 1 and 2 in a stream, retain a message, and keep a session across a restart.
  3. How it works: the ideas behind the gateway, on one page.
  4. Install the gateway, then provision the streams and buckets and deploy for high availability.