https://github.com/diamondlightsource/bluesky-stomp
STOMP messaging integration for bluesky
https://github.com/diamondlightsource/bluesky-stomp
Last synced: 3 months ago
JSON representation
STOMP messaging integration for bluesky
- Host: GitHub
- URL: https://github.com/diamondlightsource/bluesky-stomp
- Owner: DiamondLightSource
- License: apache-2.0
- Created: 2024-08-06T08:34:21.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-02-11T11:52:17.000Z (3 months ago)
- Last Synced: 2025-02-11T12:39:12.767Z (3 months ago)
- Language: Python
- Size: 130 KB
- Stars: 1
- Watchers: 6
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/DiamondLightSource/bluesky-stomp/actions/workflows/ci.yml)
[](https://codecov.io/gh/DiamondLightSource/bluesky-stomp)
[](https://pypi.org/project/bluesky-stomp)
[](https://www.apache.org/licenses/LICENSE-2.0)# Bluesky Stomp
STOMP integration for bluesky
Source |
:---: | :---:
PyPI | `pip install bluesky-stomp`
Releases |## Low Level API
The library comes with some helpers for interacting with a stomp broker:
```python
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
```