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()
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.1.tar.gz
(33.3 kB
view details)
Built Distribution
File details
Details for the file bluesky_stomp-0.1.1.tar.gz
.
File metadata
- Download URL: bluesky_stomp-0.1.1.tar.gz
- Upload date:
- Size: 33.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be2de32af8df2ab4d00c81ddf0779f2ed230c72f70978d5166360af6067d0dcf |
|
MD5 | d4ac9c3a6328fe9e4ff3985c51c1ea33 |
|
BLAKE2b-256 | 009ad852d1e5f8bd8b6cba5874dbb3bd4a0e1944dbb90d07f65134d4b0f72486 |
File details
Details for the file bluesky_stomp-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: bluesky_stomp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 695042d9bd50d73c7786f96976ca550365cf1695879c5721c7d14dc4fb46c75f |
|
MD5 | 8e275740669734f5c1d591a9ad564361 |
|
BLAKE2b-256 | c5f28da1133b6338d4ec5f46c2cff5929dea6f42c3c66929072b540a7030f41e |