SonataNotificationBundle does not consume messages

Today I was playing around with SonataNotificationBundle. I simply followed the installation instructions, but I encountered some problems.

First problem: You have to manually add SonataEasyExtendsBundle as a dependency. For some reason it is not automatically added by Composer. I guess they’ve just forgot it in the composer.json, so maybe this problem is already fixed by the time you read this.

After the bundle was working I’ve implemented a new component to dispatch some messages. Everything was working fine, I could even see the message in the database (used Doctrine for the message queue). To complete that test scenario I implemented a consumer for my message type and registered it as a tagged service. I started the consumer job as described in the documentation …

app/console sonata:notification:start --env=prod --iteration=250

… but nothing happend!

Second problem: The messages did not process. Some debugging in the code showed me that it only fetched messages with type default from the database. This was strange, because the console told me that my message consumer is registered and there was no default type at all. I did some research on this problem and found a very useful post of someone having the exact same problem. There was as a working configuration in the thread so a gave it a try – and it worked! The trick was to configure at least one queue. Your configuration should look similar to this:

sonata_notification:
    queues:
        - { queue: catchall, default: true }

The catchall is just a name for the queue, it can be anything. It’s more important to make it the default queue, which is done with default: true.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.