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.1.tar.gz (7.8 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.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fp_mqtt_broker-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 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.1.tar.gz
Algorithm Hash digest
SHA256 3b41e915fbac830cfff847bda425e35ad92744d9712ebbd13de189247de52146
MD5 bf944d473ca7bb8564585d87e4f54d7a
BLAKE2b-256 9c253e215b45a7813114bd4d2aaf5f518dcb711dfb4a1210815f2195bd339d2d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fp_mqtt_broker-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21fa7ca6311defaffe67358b89791da728928ef689ae7213aef88257f8f16288
MD5 e77cd07aaace70520e168a16c79f6f4f
BLAKE2b-256 d9dd0288f14bdee52738e140960abce57265c12974e0214c1b6be3221c24c06b

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