ForestMQ Python
Python client for ForestMQ
Install
pip install forestmq
Running ForestMQ
docker run -p 8005:8005 josefdigital/forestmq:0.6.2
Examples
Using the provider API
from forestmq import ForestMQ
def sync_example():
fmq = ForestMQ(domain="http://localhost:8005")
result = fmq.provider.send_msg_sync({
"name": "Sync message",
})
print(result)
sync_example() # {'queue_length': 38, 'message_size': 5120, 'message': {'name': 'Sync message'}}
Using the provider's async client
import asyncio
from forestmq import ForestMQ
async def async_example():
fmq = ForestMQ(domain="http://localhost:8005")
result = await fmq.provider.send_msg({
"name": "Async message!",
})
print(result)
asyncio.run(async_example()) # {'queue_length': 39, 'message_size': 5120, 'message': {'name': 'Async message!'}}
Using the consumer API
import asyncio
from forestmq import ForestMQ
def callback(message: dict) -> None:
print(f"Consumer message: {message['message']}")
if __name__ == "__main__":
fmq = ForestMQ(domain="http://localhost:8005", interval=1)
asyncio.run(fmq.consumer.poll_sync(callback))
Async consumer example
import asyncio
from forestmq import ForestMQ
async def callback(message: dict) -> None:
await asyncio.sleep(1)
print(f"Consumer message: {message['message']}")
if __name__ == "__main__":
fmq = ForestMQ(domain="http://localhost:8005", interval=1)
asyncio.run(fmq.consumer.poll(callback))
Metadata
Release files for forestmq 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| forestmq-0.2.1.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| forestmq-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.1 kB
Release files / forestmq-0.2.1.tar.gz
| Download URL | forestmq-0.2.1.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
38dc7be3dbe0cb780a5d6d540c2a69137ab7b755f2e6a62249810100a1258d18
|
|
BLAKE2b-256 checksum How to use checksums |
500b87caca72dc0c3f1dfa9d419f0fb038e9196deaaaefadf92e618cfed69d20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / forestmq-0.2.1-py3-none-any.whl
| Download URL | forestmq-0.2.1-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97e28a6faeb964a25f2cec02340f249419a36e43587968203f594b947b270a87
|
|
BLAKE2b-256 checksum How to use checksums |
5f9fb997a567531fe29903183478c69499c5895ca329cec0494d2107809ae2b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|