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.2.tar.gz
(33.3 kB
view details)
Built Distribution
File details
Details for the file bluesky_stomp-0.1.2.tar.gz
.
File metadata
- Download URL: bluesky_stomp-0.1.2.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 | 0ceeef59e08e9ccb201f8dde281f8634875a2644c06e075333f337bb8d3403b1 |
|
MD5 | e5ccbd2536d0ea029a26a65b1604289d |
|
BLAKE2b-256 | ece7d8689dd28589ec4b044e83a197f2e8c89bc8220e4827bed4bc3ac89b7df3 |
File details
Details for the file bluesky_stomp-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: bluesky_stomp-0.1.2-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 | 537324d9def4b17b753455cd3541a6d6681b2f01d19aee81ad8d19b6c62c88a2 |
|
MD5 | 923f52d159ef4c42ef3eeeb57edf89bb |
|
BLAKE2b-256 | ba0a75d96d445762f9aecdee15758d201c1c192995f617b4aee1695eea5622b2 |