brefphp / symfony-messenger

Bridge to use Symfony Messenger on AWS Lambda with Bref
MIT License
72 stars 22 forks source link

Handling messages from SQS not working #75

Closed curlysanders closed 1 year ago

curlysanders commented 1 year ago

Somehow when the consumer tries to handle a message the MessageBus doesn't have any middleware registered at Symfony\Component\Messenger\MessageBus. This is only the case when consuming async. The regular sync messages all get handled correctly. I've debugged it extensively. The messages are definitely 'consumed', but nothing happens and they're tried over and over.

I have a custom event.bus with async transport configured like this:

# config/packages/messenger.yaml
framework:
    messenger:
        default_bus: command.bus
        buses:
            command.bus:
                ...
            query.bus:
                ...
            event.bus:
                default_middleware: allow_no_handlers
                middleware:
                    - validation
                    - doctrine_transaction

        transports:
            ...
            async:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
                serializer: messenger.transport.symfony_serializer
                options:
                   auto_setup: false
            ...
        routing:
            ...
            Application\Event\Async\AsyncEvent: async

And this is in services.yaml:

    Bref\Symfony\Messenger\Service\Sqs\SqsConsumer:
        public: true
        autowire: true
        arguments:
            # Pass the transport name used in config/packages/messenger.yaml
            $transportName: 'async'
            # true enables partial SQS batch failure
            # Enabling this without proper SQS config will consider all your messages successful
            # See https://bref.sh/docs/function/handlers.html#partial-batch-response for more details.
            $partialBatchFailure: false
            $bus: '@event.bus'
            $logger: '@logger'
            $serializer: '@messenger.transport.symfony_serializer'

I'm currently using Symfony 6.3.3 and Bref 1.7.32

Running the consumer locally with the vendor/bin/bref local worker command works perfectly.

Might Bref 2 work? I'll try and upgrade tomorrow.

curlysanders commented 1 year ago

Got Bref 2.1.1 working, but sadly no difference.

curlysanders commented 1 year ago

Continued in https://github.com/brefphp/bref/issues/1520#issuecomment-1671611741