Skip to content

Instantly share code, notes, and snippets.

@mareksuscak
Created September 11, 2019 22:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mareksuscak/548723e29256b9e5bf86388a9755d4dd to your computer and use it in GitHub Desktop.
Save mareksuscak/548723e29256b9e5bf86388a9755d4dd to your computer and use it in GitHub Desktop.
Symfony 4.4 Messenger - Alternative approach to different middleware for producer and consumer
framework:
messenger:
# ...
# Read more to learn why there are two buses (TL;DR: different middleware on each side - producer and consumer)
# https://github.com/symfony/symfony/issues/32436#issuecomment-530565499
default_bus: command.bus
buses:
command.bus:
default_middleware: false
middleware:
- validation
- add_bus_name_stamp_middleware: ['command.consumer.bus']
- dispatch_after_current_bus
- failed_message_processing_middleware
- send_message
- handle_message
command.consumer.bus:
middleware:
- doctrine_ping_connection
# Will be available as of Symfony 4.4
# - doctrine_clear_entity_manager
- doctrine_transaction
@jrjohnson
Copy link

Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment