Download the PHP package vs-point/messenger-transport-mqtt without Composer
On this page you can find all versions of the php package vs-point/messenger-transport-mqtt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vs-point/messenger-transport-mqtt
More information about vs-point/messenger-transport-mqtt
Files in vs-point/messenger-transport-mqtt
Package messenger-transport-mqtt
Short Description Symfony Messenger transport for the MQTT.
License MIT
Homepage https://github.com/vs-point/messenger-transport-mqtt
Informations about the package messenger-transport-mqtt
MQTT Transport for Symfony Messenger
Symfony Messenger transport for MQTT, built on top of php-mqtt/client.
Requirements
- PHP >= 8.2
- Symfony Messenger ^7.0 | ^8.0
- A running MQTT broker (e.g. Eclipse Mosquitto)
Installation
How it works
Sending: any message class implementing MqttMessageInterface dispatched to the bus is published to the MQTT broker on the topic and with the QoS level returned by the message. Messages with QoS > 0 wait up to 300 ms for the broker acknowledgment before returning.
Receiving: the Messenger worker calls get() in a loop. Each call opens a 100 ms non-blocking poll against the broker and returns all messages that arrived during that window as MqttMessage envelopes. Subscribed topics are configured on the transport factory and established on the first get() call. All subscriptions use QoS 0.
ack() and reject() are no-ops — delivery guarantees are handled at the MQTT protocol level via QoS.
Configuration
1. Register the transport factory
$topics — list of MQTT topic filters the worker subscribes to. Wildcards (#, +) are supported.
$clientId — optional; defaults to the current process ID.
2. Configure the transport
3. Environment variables
Omit credentials for brokers that allow anonymous connections:
Usage
Sending a message
Implement MqttMessageInterface in your message class to control the topic, QoS level, and payload:
Dispatch it via the message bus:
Receiving messages
Start the Messenger worker:
The worker receives MqttMessage envelopes. Handle them with a message handler:
Note: received messages are always wrapped in
MqttMessage, regardless of the original message class used for sending. The transport does not perform any serialization —getBody()carries the raw string payload.
Development
Start the local environment
Run tests
Tests require the MQTT broker to be running (docker compose up -d mqtt):