STOMP integration for bluesky
Project description
Bluesky Stomp
STOMP integration for bluesky
| Source | https://github.com/DiamondLightSource/bluesky-stomp |
|---|---|
| PyPI | pip install bluesky-stomp |
| Releases | https://github.com/DiamondLightSource/bluesky-stomp/releases |
Low Level API
The library comes with some helpers for interacting with a stomp broker:
from bluesky_stomp.messaging import MessageContext, StompClient
from bluesky_stomp.models import Broker, MessageQueue, MessageTopic
# Assumes you have an unauthenticated broker such as ActiveMQ running on localhost:61613
client = StompClient.for_broker(Broker(host="localhost", port=61613))
try:
# Connect to the broker
client.connect()
# Send a message to a queue and a topic
client.send(MessageQueue(name="my-queue"), {"foo": 1, "bar": 2})
client.send(MessageTopic(name="my-topic"), {"foo": 1, "bar": 2})
# Subscribe to messages on a topic, print all messages received,
# assumes there is another service to post messages to the topic
def on_message(message: str, context: MessageContext) -> None:
print(message)
client.subscribe(MessageTopic(name="my-other-topic"), on_message)
# Send a message and wait for a reply, assumes there is another service
# to post the reply
reply_future = client.send_and_receive(
MessageQueue(name="my-queue"), {"foo": 1, "bar": 2}
)
print(reply_future.result(timeout=5.0))
finally:
# Disconnect at the end
client.disconnect()
python -m bluesky_stomp --version
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
bluesky_stomp-0.1.5.tar.gz
(35.3 kB
view details)
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 bluesky_stomp-0.1.5.tar.gz.
File metadata
- Download URL: bluesky_stomp-0.1.5.tar.gz
- Upload date:
- Size: 35.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
918d1f418d57b220029b649822ab8b0398c6a297b9666588395e323c437bd045
|
|
| MD5 |
50665a7e512928e2d9f75a4f23c4919a
|
|
| BLAKE2b-256 |
fe1dedaf61203db799975d7b76c86c8c356442a3a53da029a1d4343973b1aea3
|
File details
Details for the file bluesky_stomp-0.1.5-py3-none-any.whl.
File metadata
- Download URL: bluesky_stomp-0.1.5-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f831a82aadb6e5734dbbb84bcb20b04832fb50e84cc5472ccc10f26613cc0532
|
|
| MD5 |
0186af7490b2129a0592b1429ef8bb96
|
|
| BLAKE2b-256 |
ba0554ed8e58ce8f0cc2798c89ea2b138f8132ee097efce64bf5baa2b18840db
|