Coordinated Producer Consumer for MQTT
Project description
MQTT Coordinated consumer.
Kafka Motivated Coordinated Consumer for MQTT
Auto Rebalance
MQTT Consumer CoordinatorManager
CoordinatorManager class is manager class for mqtt consumer. It lets you connect to a MQTT server and subscribe to multiple topics. It gives you on_message callback for actions after receiving new message.
>>> from mqtt import CoordinatorManager
>>>
>>> manager = CoordinatorManager('my-manager', 'iot.eclipse.org')
>>> manager.start()
>>>
>>> consumer = manager.coordinated_consumer
>>> consumer.on_message = on_message # Pass callback name here.
>>> consumer.subscribe("house/bulb")
# Disconnect and stop consuming
>>> consumer.disconnect()
>>> manager.stop()
MQTT Producer CoordinatedProducer
CoordinatedProducer class is MQTT producer which will create number of partitions on MQTT topic. you can pass partition number or partition_key to this producer. Messages with same partition_key are garuanteed to be produced on same partition.
>>> from mqtt import CoordinatedProducer
>>> producer = CoordinatedProducer('iot.eclipse.org')
>>> producer.publish_on_partition("house/bulb", "on") # Message will be published on random partition
>>> producer.publish_on_partition("house/bulb", "on", partition=5) # Message will be published on 5th partition
>>> producer.publish_on_partition("house/bulb", "on", partition_key='message_key') # All messages with partition_key will be published on same partition.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mqtt_coordinated-0.0.1.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for mqtt_coordinated-0.0.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72b5b64d81c993e86730f8d52546b7d370a5ef0b682be79b8385770570a6b550 |
|
MD5 | c30684317c0409c0f37c1c49978a82ee |
|
BLAKE2b-256 | 7d5a984485ee709b87f13ad62d753781e70f6eab8d3c3b8a43dab257082f3233 |