off_broadway_mqtt v0.1.0 OffBroadway.MQTT.Client View Source

Implemens the default MQTT client that is used by the producer to connect to the broker.

The client

  • establishes the connection to OffBroadway.MQTT broker
  • subscribes to the provided topic
  • wrapping the received payload in a OffBroadway.MQTT.Data.t/0 struct.
  • enques received and wrapped messages to the passed queue

This module relies on Tortoise and Tortoise.Supervisor.start_child/1 establish the connection and subscribe to the topic.

Link to this section Summary

Types

Type for options for start/4.

Collection type for all options that can be passed to start/4

Functions

Starts a MQTT client for the passed subscription with a random client id.

Link to this section Types

Link to this type

option() View Source
option() ::
  {:sub_ack, nil | Process.dest()} | {:client_id, String.t()} | {atom(), any()}

Type for options for start/4.

  • :client_id - Can be used to set the client id for the connection. If not given a random client id is generated.
  • sub_ack - A Process.dest/0 that receives a message as soon as the subscription is acknowledged. The subscriber receives a message in the form {:subscription, client_id, topic, status}.
Link to this type

options() View Source
options() :: [option()]

Collection type for all options that can be passed to start/4

Link to this section Functions

Starts a MQTT client for the passed subscription with a random client id.

When passing :default as the first argument f:OffBroadway.MQTT.config/1 is used to figure out the connection.

Options

  • :client_id - Can be used to set the client id for the connection. If not given a random client id is generated.
  • sub_ack - A Process.dest/0 that receives a message as soon as the subscription is acknowledged. The subscriber receives a message in the form {:subscription, client_id, topic, status}.