title: How to configure Symfony Messenger to work with topic exchange?
body: <p>We have a project that partially uses DDD. When changing / creating an entity, we throw an event inside the entity. Next, the Doctrine Event Subscriber takes all the events and forwards them to the EventBus.</p>
  
  <p>Let's say we have a <code>MissionCreatedEvent</code> event. I want to make routing key <code>mission.event.created</code> for it and tie it into 2 queues: <code>new_mission_notification_to_part_time_employee</code> and <code>new_mission_area_notification_to_manager</code>.</p>
  
  <p>This is what the config looks like:</p>
  
  <pre class="lang-yaml prettyprint-override"><code>transports:
      async_new_mission_notification_to_part_time_employee:
          dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
          options:
              exchange:
                  name: mission
                  type: topic
              queues:
                  new_mission_notification_to_part_time_employee:
                      binding_keys: ['mission.event.created']
          retry_strategy:
              max_retries: 0
  
      async_new_mission_area_notification_to_manager:
          dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
          options:
              exchange:
                  name: mission
                  type: topic
              queues:
                  new_mission_area_notification_to_manager:
                      binding_keys: ['mission.event.created']
          retry_strategy:
              max_retries: 0
  
  routing:
      'App\Domain\Mission\Event\MissionCreatedEvent':
          - async_new_mission_notification_to_part_time_employee
          - async_new_mission_area_notification_to_manager
  </code></pre>
  
  <p>The problem is that Symfony Messenger first runs on transports and only then pushes the message into exchange. Since we have 2 transports, it turns out that the event with routing key <code>mission.event.created</code> is triggered twice. Because of this, my Message handlers run 2 times.</p>
  
  <p>There is an option not to use routing key <code>mission.event.created</code>. But use similar  to <code>mission.cmd.notify_part_time_employee_about_new_mission</code>
  and <code>mission.cmd.notify_manager_about_new_mission_in_area</code> for each transport with direct exchange.</p>
  
  <p>This will help solve duplication problems, but I can’t use all the features that RabbitMQ gives me :(</p>