diff --git a/docs/bundle/quick_tour.md b/docs/bundle/quick_tour.md index 08d22529a..4c54f262c 100644 --- a/docs/bundle/quick_tour.md +++ b/docs/bundle/quick_tour.md @@ -58,7 +58,14 @@ class Kernel extends BaseKernel ## Usage -First, you have to configure a transport layer and set one to be default. +First, you have to configure a transport layer. +You can optionally configure multiple transports if you want to. One of them will automatically become the default, +based on the following: +1. If there is a transport named `default`, then it will become the default. +2. First one specified otherwise. + +Default transport's services will be available to you in the usual Symfony container under their respective class +interfaces (see below) ```yaml # app/config/config.yml @@ -67,26 +74,47 @@ enqueue: default: transport: "amqp:" client: ~ + some_other_transport: + transport: "amqp:" + client: ~ ``` -Once you configured everything you can start producing messages: +Once you configured everything you can start producing messages. +As stated previously, default transport services are available in container. Here we are using `ProducerInterface` to +produce message to the `default` transport. ```php get(ProducerInterface::class); +// If you want a different producer than default (for example the other specified in sample above) then use +// $producer = $container->get('enqueue.client.some_other_transport.producer'); // send event to many consumers $producer->sendEvent('aFooTopic', 'Something has happened'); +// You can also pass an instance of Enqueue\Client\Message as second argument if you need more flexibility. +$properties = []; +$headers = []; +$message = new Message('Message body', $properties, $headers); +$producer->sendEvent('aBarTopic', $message); // send command to ONE consumer $producer->sendCommand('aProcessorName', 'Something has happened'); ``` -To consume messages you have to first create a message processor: +To consume messages you have to first create a message processor. + +Example below shows how to create a Processor that will receive messages from `aFooTopic` topic (and only that one). +It assumes that you're using default Symfony services configuration and this class is +[autoconfigured](https://symfony.com/doc/current/service_container.html#the-autoconfigure-option). Otherwise you'll +have to tag it manually. This is especially true if you're using multiple transports: if left autoconfigured, processor +will be attached to the default transport only. + +Note: Topic in enqueue and topic on some transports (for example Kafka) are two different things. ```php