framework:
  messenger:
    failure_transport: failed

    transports:
      # https://symfony.com/doc/current/messenger.html#transport-configuration
       async: '%env(MESSENGER_TRANSPORT_DSN)%'
       failed: '%env(MESSENGER_TRANSPORT_DSN)%'

    routing:
      # Route your messages to the transports
       'App\Message\CourseIndexRequest': async
       'App\Message\UserIndexRequest': async
       'App\Message\MeshDescriptorIndexRequest': async
       'App\Message\LearningMaterialIndexRequest': async

    default_bus: messenger.bus.default
    buses:
      messenger.bus.default:
        middleware:
          # each time a message is handled, the Doctrine connection
          # is "pinged" and reconnected if it's closed.
          - doctrine_ping_connection
          # After handling, the Doctrine connection is closed
          - doctrine_close_connection
      dispatch.bus:
        default_middleware: false
        middleware:
            - validation
            - add_bus_name_stamp_middleware: ['messenger.bus.default']
            - dispatch_after_current_bus
            - failed_message_processing_middleware
            - send_message
            - handle_message

framework:
  messenger:
    failure_transport: failed
    reset_on_message: true
    transports:
      # https://symfony.com/doc/current/messenger.html#transport-configuration
       async: '%env(MESSENGER_TRANSPORT_DSN)%'
       failed: '%env(MESSENGER_TRANSPORT_DSN)%'

    routing:
      # Route your messages to the transports
       'App\Message\CourseIndexRequest': async
       'App\Message\UserIndexRequest': async
       'App\Message\MeshDescriptorIndexRequest': async
       'App\Message\LearningMaterialIndexRequest': async

    default_bus: messenger.bus.default
    buses:
      messenger.bus.default:
        middleware:
          # each time a message is handled, the Doctrine connection
          # is "pinged" and reconnected if it's closed.
          - doctrine_ping_connection
          # After handling, the Doctrine connection is closed
          - doctrine_close_connection
      dispatch.bus:
        default_middleware: false
        middleware:
            - validation
            - add_bus_name_stamp_middleware: ['messenger.bus.default']
            - dispatch_after_current_bus
            - failed_message_processing_middleware
            - send_message
            - handle_message

Reset the container between messages
Reset the container between messages

This prevents leaky services like the logger from holding onto memory.
