Skip to main content

Mersal

Project

Status

CI/CD

Latest Release CI Documentation Building

Quality

https://codecov.io/github/mersal-org/mersal/graph/badge.svg?token=3219SZABYN

Package

PyPI - Version PyPI - Support Python Versions Mersal PyPI - Downloads

Meta

License - MIT types - ty types - Basedpyright types - Mypy linting - Ruff

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.10.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 mersal 0.10.0
File Size Uploaded Provenance Actions
mersal-0.10.0.tar.gz 350.5 kB With provenance Details for mersal-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mersal 0.10.0
File Interpreter ABI Platform Actions
mersal-0.10.0-py3-none-any.whl Python 3 none any Details for mersal-0.10.0-py3-none-any.whl

Total release size: 494.1 kB

Release files / mersal-0.10.0.tar.gz

Download URL mersal-0.10.0.tar.gz
Size 350.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2eb4989e2d13eafcffda7600de2f9caa5c32874d62107ef3882fdb34045cedeb
BLAKE2b-256 checksum
How to use checksums
b1fe07976f2feb64a70386b96ff7913c34dc5405b97dfd6a8bc8bddfcd477cdf
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 Sep 26, 2026.

Transparency log

Release files / mersal-0.10.0-py3-none-any.whl

Download URL mersal-0.10.0-py3-none-any.whl
Size 143.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78531e0ed2099145513885b1139b06096db1d945581fed8890f67872158cc9d1
BLAKE2b-256 checksum
How to use checksums
807435237f7ede1ebe5dda515485ebf2a71c08965d64cd08a315ad875dcd58d3
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 Sep 26, 2026.

Transparency log

Security for mersal 0.10.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mersal-0.10.0.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 Sep 26, 2026.

Transparency log

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.

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