SmsHandlerin this example. Our handler has to extend the
Shopware\Core\Framework\MessageQueue\Handler\AbstractMessageHandlerclass and implement the method
handle. To specify which methods should be handled by a given handler we implement the static method
getHandledMessagesand return a reference to the MessageClasses our handler should handle. We can also define multiple handlers for the same message. To register a handler, we have to tag it with the
defaultis the transport you want to consume message from. There is also an API-Route that lets you consume messages for a given transport. Just post to the route
/api/_action/message-queue/consumeand define the transport from which you want to consume:
CronJobthat runs the command periodically.
messenger.bus.shopware. It is mandatory to use this message bus if your messages should be handled inside Shopware. However if you want to send messages to external systems you can define your custom message bus for that.
framework.yaml, but since Shopware is integrated with Enqueue, it is best practice to configure your transport in your
enqueue.yamland simply tell Symfony to use your enqueue transports.
enqueue.yamlyou simply configure your transports as follows:
amqp://)different enqueue transports are required. Shopware just ships with the
Filesystemtransport, so you need to require the transport you want to use.
shopware.ymlconfiguration. If you want to use the admin worker you have to specify each transport, that previously was configured. The poll interval is the time in seconds that the admin-worker polls messages from the queue. After the poll-interval is over the request terminates and the administration initiates a new request.