Maxim Mironjuk
-
January 08, 2026
Once a project grows past a handful of message handlers, it quickly becomes clear that concerns like logging, execution time measurement, or wrapping work inside a database transaction shouldn't be duplicated inside every single handler. The Symfony Messenger bus solves exactly this problem with a middleware chain that every message passes through before and after reaching its handler, similar in spirit to an HTTP kernel event, but specific to the messaging layer. This article walks through implementing custom middleware, registering it at the right spot in the chain, and where the line to classic event listeners sits.