Symfony

Messenger Component

Message bus, handlers, transports, async messages, middleware, retries, failed messages

22 preguntas de entrevista·
Mid-Level
1

What is the main purpose of the Messenger component in Symfony?

Respuesta

The Messenger component allows dispatching messages to handlers, either synchronously or asynchronously via transports like RabbitMQ, Redis, or Doctrine. It facilitates building decoupled architectures by separating message emission from processing, improving application scalability and maintainability.

2

How to define a message in Symfony Messenger?

Respuesta

A message in Symfony Messenger is simply a plain PHP class (POPO) containing the data needed for processing. No interface or parent class is required. The convention is to name messages with descriptive suffixes like Notification or Command, and make them immutable with readonly properties to ensure data integrity.

3

How to create a handler to process a message in Symfony Messenger?

Respuesta

A handler is a class with an __invoke() method that receives the message as a parameter. The #[AsMessageHandler] attribute automatically registers the handler. Symfony detects the message type to handle via the parameter type-hint. This approach uses autowiring and avoids manual configuration in services.yaml.

4

Which interface should be injected to dispatch a message in Symfony Messenger?

5

What is an Envelope in the context of Symfony Messenger?

+19 preguntas de entrevista

Domina Symfony para tu próxima entrevista

Accede a todas las preguntas, flashcards, tests técnicos, ejercicios de code review y simuladores de entrevista.

Empieza gratis