AiD
AiD

Reputation: 1007

Difference between EventDispatcher and Messenger

What is the basic difference between dispatching an Event by Messenger and dispatching an Event by Symfony EventDispatcher Component ?

Upvotes: 1

Views: 1912

Answers (2)

Manu
Manu

Reputation: 445

Symfony Messenger is a tool to help you building a bus messenger system. Typically, you would use it if your application needs to communicate with external services (using an AMQP protocol, for example).

The EventDispatcher system gives your components the ability to communicate between them. You'll use this system if you want to make inner parts of your application communicate.

Upvotes: 7

Nico Haase
Nico Haase

Reputation: 12130

As you've already tagged this question with RabbitMQ: have you tried to use the EventDispatcher and RabbitMQ? I don't think this is possible.

But to cite the official documentation, located at https://symfony.com/doc/current/components/messenger.html:

The Messenger component helps applications send and receive messages to/from other applications or via message queues.

The pure ability to handle a message in another request (through using a transport) makes a huge difference to the EventDispatcher, which handles all given events in the same instance of your application. Restarting the application (through a new shell call, or a new web server request) will definitely kill all events that have not been handled yet through the EventDispatcher, but those stored using a transport might still be there

Upvotes: 3

Related Questions