diff --git a/docs/bundle/message_producer.md b/docs/bundle/message_producer.md index bda5152d2..ecb0603e2 100644 --- a/docs/bundle/message_producer.md +++ b/docs/bundle/message_producer.md @@ -9,18 +9,18 @@ Enqueue is an MIT-licensed open source project with its ongoing development made # Message producer -You can choose how to send messages either using a transport directly or with the client. +You can choose how to send messages either using a transport directly or with the client. Transport gives you the access to all transport specific features so you can tune things where the client provides you with easy to use abstraction. - + ## Transport - + ```php get('enqueue.transport.context'); +$context = $container->get('enqueue.transport.[transport_name].context'); $context->createProducer()->send( $context->createQueue('a_queue'), @@ -30,15 +30,15 @@ $context->createProducer()->send( ## Client -The client is shipped with two types of producers. The first one sends messages immediately +The client is shipped with two types of producers. The first one sends messages immediately where another one (it is called spool producer) collects them in memory and sends them `onTerminate` event (the response is already sent). -The producer has two types on send methods: +The producer has two types on send methods: * `sendEvent` - Message is sent to topic and many consumers can subscribe to it. It is "fire and forget" strategy. The event could be sent to "message bus" to other applications. * `sendCommand` - Message is to ONE exact consumer. It could be used as "fire and forget" or as RPC. The command message is always sent in scope of current application. - -### Send event + +### Send event ```php get(SpoolProducer::class); // message is being sent on console.terminate or kernel.terminate event $spoolProducer->sendEvent('a_topic', 'Hello there!'); -// you could send queued messages manually by calling flush method +// you could send queued messages manually by calling flush method $spoolProducer->flush(); ``` -### Send command +### Send command ```php get(SpoolProducer::class); // message is being sent on console.terminate or kernel.terminate event $spoolProducer->sendCommand('a_processor_name', 'Hello there!'); -// you could send queued messages manually by calling flush method +// you could send queued messages manually by calling flush method $spoolProducer->flush(); ```