0

so as title says, my message in Symfony is not handled. not at all. not even an error comes out.

so my messenger config is totally default. however I set multiple buses like it is showen below

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'
            - '../src/Tests/'

    # controllers are imported separately to make sure services can be injected
    # as action arguments even if you don't extend any base controller class
    App\Controller\:
        resource: '../src/Controller/'
        tags: ['controller.service_arguments']

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones

    ###MESAGE BUS
    _instanceof:
        App\App\Shared\Domain\Bus\CommandBusHandler:
            tags: [{ name: messenger.message_handler, bus: command.bus }]

        App\App\Shared\Domain\Bus\QueryBusHandler:
            tags: [{ name: messenger.message_handler, bus: query.bus }]

        App\App\Shared\Domain\Bus\EventBusHandler:
            tags: [{ name: messenger.message_handler, bus: event.bus }]

    command.bus.dispatcher:
        class: App\App\Shared\Infrastructure\Symfony\MessageBus
        arguments:
            $messageAllowedType: 'App\App\Shared\Domain\Bus\Message\CommandMessageInterface'

    query.bus.dispatcher:
        class: App\App\Shared\Infrastructure\Symfony\MessageBus
        arguments:
            $messageAllowedType: 'App\App\Shared\Domain\Bus\Message\QueryMessageInterface'

    event.bus.dispatcher:
        class: App\App\Shared\Infrastructure\Symfony\MessageBus
        arguments:
            $messageAllowedType: 'App\App\Shared\Domain\Bus\Message\EventMessageInterface'

    App\App\Shared\Infrastructure\Symfony\BlackBirdMessageBusInterface $commandDispatcher: '@command.bus.dispatcher'
    App\App\Shared\Infrastructure\Symfony\BlackBirdMessageBusInterface $query: '@query.bus.dispatcher'
    App\App\Shared\Infrastructure\Symfony\BlackBirdMessageBusInterface: '@event.bus.dispatcher'

my output of bin/console debug:mess is: enter image description here

what I notice in class:\Symfony\Component\Messenger\Handler\HandlersLocator empty array is passed as handlers list in constructor.

I use symfony and symfony/messenger in 5.2 version

and my dispatcher proxy if important:

class MessageBus implements BlackBirdMessageBusInterface
 {
  private MessageBusInterface $messageBus;

  private TranslatorInterface $translator;

  private string $messageAllowedType = ''; //if empty allow all types

  public function __construct(
      MessageBusInterface $messageBus,
      TranslatorInterface $translator,
      string $messageAllowedType = ''
  )
  { 
      $this->messageBus = $messageBus;
      $this->translator = $translator;
      $this->messageAllowedType = $messageAllowedType;
  }



  public function publish(array $events): void
  {
      foreach ($events as $event) {
          $this->dispatch($event);
      }
  }

  public function dispatch($message, array $stamps = []): Envelope
  {
      // $this->guardMessageType($message);

      return $this->messageBus->dispatch($message, $stamps);
  }

  private function guardMessageType($message)
  {
      if (false === empty($this->messageAllowedType) && false === is_a($message, $this->messageAllowedType)) {
          throw  new \LogicException($this->translator->trans('dispatcher.wrong_message'));
      }
  }

}

adeptofvoltron
  • 369
  • 1
  • 9
  • What happens when you run `bin/console messenger:consume -vv` ? Do you get any helpful output? – domagoj Mar 12 '21 at 14:19
  • In ConsumeMessagesCommand.php line 133: [Symfony\Component\Console\Exception\RuntimeException] Please pass at least one receiver. – adeptofvoltron Mar 13 '21 at 16:11

0 Answers0