Skip to main content

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.

Confirming publication

By default publish() returns once the frame has been written to the socket, which does not mean the broker accepted the message. Pass receipt_timeout to wait for the broker's STOMP RECEIPT instead. It follows the same precedence as add_content_length: per-call, then publisher, then broker default.

broker = faststream_stomp.StompBroker(stompman.Client([server]), receipt_timeout=3.0)
publisher = broker.publisher("events", receipt_timeout=5.0)

await broker.publish("text message", "events", receipt_timeout=1.0)
await publisher.publish("another message")

The default is None everywhere, which preserves the existing behavior. A failed confirmation raises stompman.SendReceiptError from publish(), with reason equal to rejected, timeout, or connection_lost.

timeout and connection_lost are ambiguous outcomes: the broker may have accepted the message even though its receipt was lost. Nothing is replayed automatically: give each application event a stable ID and deduplicate in the broker or downstream consumer if you retry. JMSCorrelationID alone does not deduplicate anything. And a receipt only means the broker took ownership: it does not mean a consumer has processed the message.

receipt_timeout is not available for batch publishing, which publishes inside a transaction: a receipt for a transactional SEND says nothing about whether the COMMIT succeeded. A broker or publisher default is ignored there rather than silently claiming confirmation.

Caveats

  • When exception is raised in consumer handler, the message will be nacked (FastStream doesn't do this by default)

Metadata

Release files for faststream-stomp 2.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for faststream-stomp 2.9.0
File Size Uploaded Provenance Actions
faststream_stomp-2.9.0.tar.gz 10.4 kB Without provenance Details for faststream_stomp-2.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for faststream-stomp 2.9.0
File Interpreter ABI Platform Actions
faststream_stomp-2.9.0-py3-none-any.whl Python 3 none any Details for faststream_stomp-2.9.0-py3-none-any.whl

Total release size: 26.2 kB

Release files / faststream_stomp-2.9.0.tar.gz

Download URL faststream_stomp-2.9.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5e1e070297b0d19de99f68d84a71d8fdcdc8c0413f10e1a3632bd464769e067b
BLAKE2b-256 checksum
How to use checksums
14a3812229d3d2d3d10b6b40dc4e75c0140971cbec307b0e28a1586957c03525
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / faststream_stomp-2.9.0-py3-none-any.whl

Download URL faststream_stomp-2.9.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba30c5e330c49d69f2ab368c5bc6a693561611fc7311e94624e7f96bf566c9da
BLAKE2b-256 checksum
How to use checksums
a1e62a612dca25986dc24046a1a497cffffb2e92625394f4c70654ae6aaed908
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for faststream-stomp 2.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.9.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page