Backend

Backends

TIP

Data storage is an exclusive feature of EMQX Enterprise.

MQTT Message Persistence

One-to-one message Persistence

image

  1. PUB publishes a message;
  2. Backend records this message in DB;
  3. SUB subscribes to a topic;
  4. Backend retrieves the messages of this topic from DB;
  5. Messages are sent to SUB;
  6. Once the SUB acknowledged / received the message, backend removes the message from DB.

Many-to-many message Persistence

image

  1. PUB publishes a message;
  2. Backend records the message in DB;
  3. SUB1 and SUB2 subscribe to a topic;
  4. Backend retrieves the messages of this topic;
  5. Messages are sent to SUB1 and SUB2;
  6. Backend records the read position of SUB1 and SUB2, the next message’s retrieval starts from this position.

Client Connection State

EMQX supports retaining the client’s connection state in Redis or DB.

Client Subscription by Broker

EMQX Persistence supports subscription by broker. When a client goes online, the persistence module loads the subscriptions of the client from Redis or Databases.

List of Persistence Plugins

EMQX allowes storing messages in Redis, MySQL, PostgreSQL, MongoDB, Cassandra, DynamoDB, InfluxDB, OpenTSDB and Timescale:

Persistence Plugins Config File Description
emqx_backend_redis emqx_backend_redis.conf Redis Message Persistence
emqx_backend_mysql emqx_backend_mysql.conf MySQL Message Persistence
emqx_backend_pgsql emqx_backend_pgsql.conf PostgreSQL Message Persistence
emqx_backend_mongo emqx_backend_mongo.conf MongoDB Message Persistence
emqx_backend_cassa emqx_backend_cassa.conf Cassandra Message Persistence
emqx_backend_dynamo emqx_backend_dynamo.conf DynamoDB Message Persistence
emqx_backend_influxdb emqx_backend_influxdb.conf InfluxDB Message Persistence
emqx_backend_opentsdb emqx_backend_opentsdb.conf OpenTSDB Message Persistence
emqx_backend_timescale emqx_backend_timescale.conf Timescale Message Persistence