Mersal
Project |
Status |
|---|---|
CI/CD |
|
Quality |
|
Package |
|
Meta |
|
Mersal is a service bus library for Python. It helps you build message driven systems (a.k.a event driven architecture).
There will be more here eventually but here is an LLM summary of core features in Mersal:
Transport agnostic: AWS SNS/SQS, GCP Pub/Sub, RabbitMQ, Azure Servicebus, it’s your choice!
Pub/sub - subscribe to events across independently running apps, with autosubscribe support so wiring stays out of your way.
Sagas - coordinate a business process that spans multiple messages over time, with pluggable storage for the saga’s state.
The outbox pattern - persist outgoing messages in the same transaction as your business data, so a handler’s side effects and its database write succeed or fail together.
Idempotent handling - process the same message more than once without corrupting state.
Retries and error handling - configurable retry strategies with dead-lettering to an error queue once a message keeps failing, so nothing is silently dropped.
A transport bridge - route messages to specific destinations through a different transport than the rest of the system, useful for migrations, cost/efficiency tradeoffs, or testing.
Pluggable persistence, and serialization
Unit of work and a request/response-style pipeline - hook into message handling to add your own cross-cutting behavior, the same way middleware works in a web framework.
Head to the quick start to build a small message-driven system in a few minutes, or the full documentation for everything else.
Acknowledgments ♥
This is a personal acknowledgment from myself (@abdulhaq-e), the main author of Mersal.
First, to the book Architecture Patterns with Python (“Cosmic Python”) and its two authors, Harry Percival (@hjwp) and Bob Gregory (@bobthemighty). Its impact on my career is substantial and cannot be compared to any other material I came by. In addition, the book is why we have Mersal.
I was following the book before its official release via its git repository. I completed every example, studied all patterns, read all the side material and years later, I still go back to it. It is like watching and rewatching a favourite TV show! I really recommend anyone who is building systems using Python (or any other language actually) to study from this book, especially if someone wants to adopt Domain Driven Design (DDD).
In Part 2 of the book, the authors introduce the concept of Event Driven Architecture and the idea of a “message bus”. Once I started building a system and applying my learnings, the system message bus was more or less the message bus from the book. From one system to the next, the bus was extracted into a reusable package and for years it was “pyservicebus”. This now brings me to the second acknowledgment. Before that, thank you, Harry and Bob, for writing the book, and for putting so much effort into it and for writing/releasing it as an open book. ♥
The current state of Mersal is significantly different than how pyservicebus looked like. I still have the commits stored somewhere with all the cursing and trials. Building a service bus that abstracts transport mechanism isn’t an easy job. So why not build on the shoulder of giants. While learning more about the concept of a message bus, I did come by NServiceBus and they have great learning materials regarding the topic and message driven architecture in general. NServicebus is OSS but their product is what you can consider as a gigantic framework with all batteries included. When looking for inspiration for Mersal, I wanted something lighter and that’s when I found Rebus, it’s a .NET service bus designed to provide a “lean” offering. While Mersal might have drifted since, I’d still agree to call it the “Python replica of Rebus”. Huge thanks to Mogens Heller Grabe (@mookid8000), Rebus’s core developer, for building and maintaining it so well for so long that it was worth learning from and borrowing this much from. ♥
Finally, a shout out to Litestar. A number of things in Mersal, from small utilities to bigger design decisions, were copied or heavily inspired by code in the Litestar organization’s repositories. Thanks to everyone there for building something worth learning from and borrowing from as well.
Metadata
Release files for mersal 0.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mersal-0.9.1.tar.gz | 318.8 kB | With provenance | Details for mersal-0.9.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mersal-0.9.1-py3-none-any.whl | Python 3 | none | any | Details for mersal-0.9.1-py3-none-any.whl |
Total release size: 451.6 kB
Release files / mersal-0.9.1.tar.gz
| Download URL | mersal-0.9.1.tar.gz |
|---|---|
| Size | 318.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
357c1253a4a537cca698988c2a26b1aa2b8f3c7b3a491a3fc23c488aec7dd4c4
|
|
BLAKE2b-256 checksum How to use checksums |
b98c84b8495ce975d39ede6d952146da1f40194664456d2cc8e7f6a293d188d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.
Transparency logRelease files / mersal-0.9.1-py3-none-any.whl
| Download URL | mersal-0.9.1-py3-none-any.whl |
|---|---|
| Size | 132.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a3385ddd948f4a88a8be09934ce7ceca1016aeed3e8d02676b9fd2f2c622ea5
|
|
BLAKE2b-256 checksum How to use checksums |
af97c8ef87c4814d78ca9765b27e610eb010ac39f221349e3c2bd7f699aec453
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.
Transparency logSecurity for mersal 0.9.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mersal-0.9.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.
Transparency logA 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.