FastStream STOMP broker
How To Use
Install the package:
uv add faststream-stomp
poetry add faststream-stomp
Basic usage:
import asyncio
import faststream
import faststream_stomp
import stompman
server = stompman.ConnectionParameters(host="127.0.0.1", port=61616, login="admin", passcode="password")
broker = faststream_stomp.StompBroker(stompman.Client([server]))
@broker.subscriber("first")
@broker.publisher("second")
def _(message: str) -> str:
print(message) # this will print message from startup
return "Hi from first handler!"
@broker.subscriber("second")
def _(message: str) -> None:
print(message) # this will print message from first handler
app = faststream.FastStream(broker)
@app.after_startup
async def send_first_message() -> None:
await broker.connect()
await broker.publish("Hi from startup!", "first")
if __name__ == "__main__":
asyncio.run(app.run())
Also there are StompRouter and TestStompBroker for testing. It works similarly to built-in brokers from FastStream, I recommend to read the original FastStream documentation.
By default, published frames include the STOMP content-length header. You can change this for the whole broker or
override it for a publisher or individual publish call:
broker = faststream_stomp.StompBroker(stompman.Client([server]), add_content_length=False)
publisher = broker.publisher("events", add_content_length=True)
await broker.publish("text message", "events", add_content_length=False)
await publisher.publish("bytes message")
Use reply_add_content_length on subscriber() when automatic replies need a different setting. The same options
are available for batch publishing and delayed StompRoute/StompRoutePublisher registrations. Per-call settings
override publisher or subscriber reply defaults, which in turn override the broker default.
Caveats
- When exception is raised in consumer handler, the message will be nacked (FastStream doesn't do this by default)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 faststream_stomp-2.6.0.tar.gz.
File metadata
- Download URL: faststream_stomp-2.6.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
540a6d03e50fdad35d9abd1d5146321c0772fff25c0e04f9399c1522f4a30318
|
|
| MD5 |
99633dba6e0dfcb87f9579a813149601
|
|
| BLAKE2b-256 |
1729bd5c12ed84deca41ddd51b182078b9fc8be0bf6d22c3c317892879c5ac5a
|
File details
Details for the file faststream_stomp-2.6.0-py3-none-any.whl.
File metadata
- Download URL: faststream_stomp-2.6.0-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd156f751161a4596b7bc9538a8eb44b42d29dcfc2ad998b9ed50055bb93ce30
|
|
| MD5 |
51090a60a7e1b7846d2804c5a31f08ef
|
|
| BLAKE2b-256 |
295586062a9d0bba289a6e95fa46bfce0c7cbed2c558d9468e74114f9a6c7f64
|