Coordinated Producer Consumer for MQTT
Project description
## MQTT Coordinated consumer.
Kafka Motivated Coordinated Consumer for MQTT
pip install mqtt-coordinated
## 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") >>> consumer.poll(100) # Batch message reading construct for streaming purpose `
` # Disconnect and stop consuming >>> consumer.disconnect() >>> manager.stop() `
There are 2 methods for consuming events, - registering for on_message - Reading messages in batches. Batches are internally stored in memory, and not stored on persistent disc for now.
## 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mqtt_coordinated-0.0.2.tar.gz.
File metadata
- Download URL: mqtt_coordinated-0.0.2.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.1+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
423ed7c6424864ea606284551c08b74468d3fad04ca60b64eb8026963b646a5d
|
|
| MD5 |
7a543dfee60d731ac0f9fc784d687c3c
|
|
| BLAKE2b-256 |
8431a4f052c885b32f3e7faeddb48df0d6285e549fa293dda91b39eaa8c67e73
|
File details
Details for the file mqtt_coordinated-0.0.2-py3-none-any.whl.
File metadata
- Download URL: mqtt_coordinated-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.1+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76382fdfab9309c2f2e9d4e185f59acf77feba7bed2e7a45756202a5843235e9
|
|
| MD5 |
999b4511e9492fa9aa26bc7e5aa158ae
|
|
| BLAKE2b-256 |
e24994b859d4a03b4158efd4d145b3e0bbf80e8050ab06919fa389a2612ef0fd
|