Skip to main content

A flexible MQTT broker package for IoT services with optional message handlers

Project description

FP MQTT Broker Package

A flexible MQTT broker package for IoT services that supports optional message handlers, allowing different services to subscribe and handle MQTT messages independently.

Features

  • Flexible Message Handling: Support for multiple, optional message handlers
  • Easy Configuration: Simple configuration through dictionaries or BrokerConfig objects
  • Extensible: Abstract interfaces for easy customization
  • Production Ready: Built-in error handling, reconnection logic, and logging

Installation

pip install -e .

Usage

from fp_mqtt_broker import BrokerFactory
from fp_mqtt_broker.abstractions import MessageHandler

config = {
    'mqtt': {
        'broker_host': 'localhost',
        'broker_port': 1883,
        'client_id': 'my_service'
    }
}

# Define a custom message handler
class MyMessageHandler(MessageHandler):
    def get_subscribed_topics(self) -> list:
        return ['my/topic']

    def handle_message(self, topic: str, payload: str):
        print(f"Received message on {topic}: {payload}")

# Create and connect the broker with the custom message handler
broker = BrokerFactory.create_broker(config, [MyMessageHandler()])
broker.connect()

Testing

pytest -v

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fp_mqtt_broker-0.1.2.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fp_mqtt_broker-0.1.2-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file fp_mqtt_broker-0.1.2.tar.gz.

File metadata

  • Download URL: fp_mqtt_broker-0.1.2.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for fp_mqtt_broker-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7f2a8f75cc2fdbd94bbd2055f9a5c6c01f19278d09c9e282ca1969023ceb7946
MD5 28bec6905ca685934ff501ef3ab4ab2a
BLAKE2b-256 deaa33388ba8e5ba6608eb5e74fbd0574e94b19e248b74f30b71a73cd87d740b

See more details on using hashes here.

File details

Details for the file fp_mqtt_broker-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: fp_mqtt_broker-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for fp_mqtt_broker-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ab06c3c092d81b1632f65767f3dc6628445335bcffd67999c6bf9f3f9cd6ffe8
MD5 1c9de46e75bd398e26289e155d89a431
BLAKE2b-256 af4a52ab34ab55751cb4a38dceb578400829d1a50269e9232e4f192460e0c153

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page