class

LavinMQ::AMQP::MqttTopicExchange

Inherits LavinMQ::MQTT::Subscriber < LavinMQ::AMQP::Exchange < LavinMQ::SortableJSON < LavinMQ::Stats < LavinMQ::PolicyTarget < LavinMQ::Exchange < LavinMQ::SortableJSON < Reference < Object

Routes MQTT publishes to AMQP destinations. Queues and exchanges are bound with MQTT topic filter syntax ("a/+/c", "a/b/#"), and a delivered message's routing key is the MQTT topic verbatim.

The exchange registers itself in the vhost's SubscriptionTree, once per distinct binding key, and fans out to its own bindings on deliver.

Constructors

new(vhost : VHost, name : String, durable = false, auto_delete = false, internal = false, arguments = AMQP::Table.new)

internal is forced: AMQP publishes can't enter this exchange, only MQTT publishes reach it, through the subscription tree.

Source

Instance methods

bind(destination : AMQP::Destination, routing_key, arguments = nil) : Bool

This macro will find the "bind" method of classes inheriting from this class and redefine them to raise AccessRefused exception if the first argument isn't a type in LavinMQ::AMQP namespace.

TODO remove this when LavinMQ::MQTT::Session no longer inherit from LavinMQ::AMQP::Queue and LavinMQ::MQTT::Exchange no longer inherit from lavinMQ::AMQP::Exchange

binding_count

Number of bindings on this exchange. Counted cheaply, without allocating the full bindings_details array.

Source
bindings_details

No return-type restriction: AMQP exchanges return Array(AMQP::BindingDetails) while MQTT::Exchange overrides this to return Array(MQTT::SubscriptionDetails).

Source
deliver(msg : Message, filter : String, ctx : MQTT::PublishContext) : Bool

A fresh Message struct: the one the tree walk hands out is shared and its delivery_mode is rewritten per entry. delivery_mode 2 is metadata only; persistence is derived from queue durability.

The tree calls this once per matching filter, so a publish matched by several filters arrives several times with the same context. It is counted in publish_in once, and in unroutable at most once. The per-publish state lives in the context, on the publishing fiber, so a publish parked in a queue's store lock is not disturbed by another client's publish into this exchange.

Source
handle_arguments
Source
match?(type, durable, auto_delete, internal, arguments)

internal is forced true in the constructor, so ignore the flag here to keep a redeclare with internal: false idempotent.

Source
routes_amqp_messages?

Whether messages routed in from AMQP, e.g. dead-lettered, reach destinations. MQTT exchanges only route MQTT publishes.

Source
type
Source
unbind(destination : AMQP::Destination, routing_key, arguments = nil) : Bool
Source