From e43a063faff4229c9b65c6172aed15a5bf41a65d Mon Sep 17 00:00:00 2001 From: Yuriy Borovchuk Date: Wed, 31 Oct 2018 11:25:21 +0200 Subject: [PATCH] Fixed docs. Removed prefix Psr --- docs/async_event_dispatcher/quick_tour.md | 8 +-- docs/bundle/async_events.md | 4 +- docs/bundle/config_reference.md | 2 +- docs/bundle/job_queue.md | 34 ++++----- docs/bundle/message_processor.md | 20 +++--- docs/bundle/message_producer.md | 2 +- docs/bundle/quick_tour.md | 10 +-- docs/client/quick_tour.md | 8 +-- docs/client/rpc_call.md | 8 +-- docs/consumption/message_processor.md | 54 +++++++------- docs/job_queue/run_sub_job.md | 14 ++-- docs/job_queue/run_unique_job.md | 10 +-- docs/laravel/quick_tour.md | 8 +-- docs/magento/quick_tour.md | 10 +-- docs/magento2/quick_tour.md | 10 +-- docs/monolog/send-messages-to-mq.md | 8 +-- docs/quick_tour.md | 78 ++++++++++---------- docs/transport/amqp.md | 86 +++++++++++------------ docs/transport/amqp_bunny.md | 86 +++++++++++------------ docs/transport/amqp_lib.md | 86 +++++++++++------------ docs/transport/dbal.md | 48 ++++++------- docs/transport/filesystem.md | 40 +++++------ docs/transport/gearman.md | 26 +++---- docs/transport/gps.md | 24 +++---- docs/transport/kafka.md | 36 +++++----- docs/transport/mongodb.md | 56 +++++++-------- docs/transport/null.md | 2 +- docs/transport/pheanstalk.md | 26 +++---- docs/transport/redis.md | 52 +++++++------- docs/transport/sqs.md | 40 +++++------ docs/transport/stomp.md | 26 +++---- 31 files changed, 461 insertions(+), 461 deletions(-) diff --git a/docs/async_event_dispatcher/quick_tour.md b/docs/async_event_dispatcher/quick_tour.md index 115ba57db..9668e5398 100644 --- a/docs/async_event_dispatcher/quick_tour.md +++ b/docs/async_event_dispatcher/quick_tour.md @@ -81,7 +81,7 @@ $dispatcher->dispatch('the_event', new GenericEvent('theSubject')); // consume.php -use Interop\Queue\PsrProcessor; +use Interop\Queue\Processor; require_once __DIR__.'/vendor/autoload.php'; include __DIR__.'/config.php'; @@ -93,13 +93,13 @@ while (true) { $result = $asyncProcessor->process($message, $context); switch ((string) $result) { - case PsrProcessor::ACK: + case Processor::ACK: $consumer->acknowledge($message); break; - case PsrProcessor::REJECT: + case Processor::REJECT: $consumer->reject($message); break; - case PsrProcessor::REQUEUE: + case Processor::REQUEUE: $consumer->reject($message, true); break; default: diff --git a/docs/bundle/async_events.md b/docs/bundle/async_events.md index 84c347e85..7a2b10a7f 100644 --- a/docs/bundle/async_events.md +++ b/docs/bundle/async_events.md @@ -87,7 +87,7 @@ namespace AcmeBundle\Listener; use Enqueue\Client\Message; use Enqueue\Consumption\Result; -use Interop\Queue\PsrMessage; +use Interop\Queue\Message as QueueMessage; use Enqueue\Util\JSON; use Symfony\Component\EventDispatcher\Event; use Enqueue\AsyncEventDispatcher\EventTransformer; @@ -132,7 +132,7 @@ class FooEventTransformer implements EventTransformer /** * {@inheritdoc} */ - public function toEvent($eventName, PsrMessage $message) + public function toEvent($eventName, QueueMessage $message) { $data = JSON::decode($message->getBody()); diff --git a/docs/bundle/config_reference.md b/docs/bundle/config_reference.md index a2dc2f0f6..000b3db2b 100644 --- a/docs/bundle/config_reference.md +++ b/docs/bundle/config_reference.md @@ -12,7 +12,7 @@ enqueue: # The broker DSN. These schemes are supported: "file", "amqp", "amqps", "db2", "ibm-db2", "mssql", "sqlsrv", "mysql", "mysql2", "pgsql", "postgres", "sqlite", "sqlite3", "null", "gearman", "beanstalk", "kafka", "rdkafka", "redis", "stomp", "sqs", "gps", "mongodb", to use these "file", "amqp", "amqps", "db2", "ibm-db2", "mssql", "sqlsrv", "mysql", "mysql2", "pgsql", "postgres", "sqlite", "sqlite3", "null", "gearman", "beanstalk", "kafka", "rdkafka", "redis", "stomp", "sqs", "gps", "mongodb" you have to install a package. dsn: ~ # Required - # The connection factory class should implement "Interop\Queue\PsrConnectionFactory" interface + # The connection factory class should implement "Interop\Queue\ConnectionFactory" interface connection_factory_class: ~ # The factory class should implement "Enqueue\ConnectionFactoryFactoryInterface" interface diff --git a/docs/bundle/job_queue.md b/docs/bundle/job_queue.md index 67ebd8367..7187974a0 100644 --- a/docs/bundle/job_queue.md +++ b/docs/bundle/job_queue.md @@ -84,15 +84,15 @@ Here's how to do it: jobRunner = $jobRunner; } - public function process(PsrMessage $message, PsrContext $context) + public function process(Message $message, Context $context) { $data = JSON::decode($message->getBody()); @@ -160,11 +160,11 @@ use Enqueue\JobQueue\JobRunner; use Enqueue\JobQueue\Job; use Enqueue\Client\ProducerInterface; use Enqueue\Util\JSON; -use Interop\Queue\PsrMessage; -use Interop\Queue\PsrContext; -use Interop\Queue\PsrProcessor; +use Interop\Queue\Message; +use Interop\Queue\Context; +use Interop\Queue\Processor; -class Step1Processor implements PsrProcessor +class Step1Processor implements Processor { /** * @var JobRunner @@ -176,7 +176,7 @@ class Step1Processor implements PsrProcessor */ private $producer; - public function process(PsrMessage $message, PsrContext $context) + public function process(Message $message, Context $context) { $data = JSON::decode($message->getBody()); @@ -207,14 +207,14 @@ class Step1Processor implements PsrProcessor } } -class Step2Processor implements PsrProcessor +class Step2Processor implements Processor { /** * @var JobRunner */ private $jobRunner; - public function process(PsrMessage $message, PsrContext $context) + public function process(Message $message, Context $context) { $data = JSON::decode($message->getBody()); @@ -244,11 +244,11 @@ use Enqueue\JobQueue\JobRunner; use Enqueue\JobQueue\Job; use Enqueue\JobQueue\DependentJobService; use Enqueue\Util\JSON; -use Interop\Queue\PsrMessage; -use Interop\Queue\PsrContext; -use Interop\Queue\PsrProcessor; +use Interop\Queue\Message; +use Interop\Queue\Context; +use Interop\Queue\Processor; -class ReindexProcessor implements PsrProcessor +class ReindexProcessor implements Processor { /** * @var JobRunner @@ -260,7 +260,7 @@ class ReindexProcessor implements PsrProcessor */ private $dependentJob; - public function process(PsrMessage $message, PsrContext $context) + public function process(Message $message, Context $context) { $data = JSON::decode($message->getBody()); diff --git a/docs/bundle/message_processor.md b/docs/bundle/message_processor.md index 674bed2d3..ba361ef7d 100644 --- a/docs/bundle/message_processor.md +++ b/docs/bundle/message_processor.md @@ -36,9 +36,9 @@ It is handy to subscribe on event messages. It allows to keep subscription login namespace AppBundle\Async; use Enqueue\Client\TopicSubscriberInterface; -use Interop\Queue\PsrProcessor; +use Interop\Queue\Processor; -class SayHelloProcessor implements PsrProcessor, TopicSubscriberInterface +class SayHelloProcessor implements Processor, TopicSubscriberInterface { public static function getSubscribedTopics() { @@ -52,9 +52,9 @@ On the topic subscriber you can also define queue and processor name: ```php get('enqueue.transport.context'); $context->createProducer()->send( diff --git a/docs/bundle/quick_tour.md b/docs/bundle/quick_tour.md index 208b78587..4ad3edabe 100644 --- a/docs/bundle/quick_tour.md +++ b/docs/bundle/quick_tour.md @@ -73,14 +73,14 @@ To consume messages you have to first create a message processor: ```php getBody(); diff --git a/docs/client/quick_tour.md b/docs/client/quick_tour.md index d7ebb27fe..879ff0f8b 100644 --- a/docs/client/quick_tour.md +++ b/docs/client/quick_tour.md @@ -84,15 +84,15 @@ $replyMessage->getBody(); ```php bindTopic('a_bar_topic', function(PsrMessage $psrMessage) { +$client->bindTopic('a_bar_topic', function(Message $psrMessage) { // processing logic here - return PsrProcessor::ACK; + return Processor::ACK; }); $client->consume(); diff --git a/docs/client/rpc_call.md b/docs/client/rpc_call.md index 01420fba3..3d6dc15d0 100644 --- a/docs/client/rpc_call.md +++ b/docs/client/rpc_call.md @@ -14,19 +14,19 @@ Of course it is possible to implement rpc server side based on transport classes ```php bindCommand('square', function (PsrMessage $message, PsrContext $context) use (&$requestMessage) { +$client->bindCommand('square', function (Message $message, Context $context) use (&$requestMessage) { $number = (int) $message->getBody(); return Result::reply($context->createMessage($number ^ 2)); diff --git a/docs/consumption/message_processor.md b/docs/consumption/message_processor.md index 9492a4c8d..a89f45dee 100644 --- a/docs/consumption/message_processor.md +++ b/docs/consumption/message_processor.md @@ -13,13 +13,13 @@ Here's example: ```php mailer->send('foo@example.com', $message->getBody()); @@ -40,14 +40,14 @@ Look at the next example that shows the message validation before sending a mail ```php getBody()); if ($user = $this->userRepository->find($data['userId'])) { @@ -67,13 +67,13 @@ If it returns true than there was attempt to process message. ```php isRedelivered()) { return self::REQUEUE; @@ -90,13 +90,13 @@ The second argument is your context. You can use it to send messages to other qu ```php mailer->send('foo@example.com', $message->getBody()); @@ -117,17 +117,17 @@ Don't forget to add `ReplyExtension`. ```php mailer->send('foo@example.com', $message->getBody()); @@ -137,9 +137,9 @@ class SendMailProcessor implements PsrProcessor } } -/** @var \Interop\Queue\PsrContext $psrContext */ +/** @var \Interop\Queue\Context $context */ -$queueConsumer = new QueueConsumer($psrContext, new ChainExtension([ +$queueConsumer = new QueueConsumer($context, new ChainExtension([ new ReplyExtension() ])); diff --git a/docs/job_queue/run_sub_job.md b/docs/job_queue/run_sub_job.md index b5f6cb65d..448f9a35b 100644 --- a/docs/job_queue/run_sub_job.md +++ b/docs/job_queue/run_sub_job.md @@ -7,14 +7,14 @@ They will be executed in parallel. ```php jobRunner->runUnique($message->getMessageId(), 'aJobName', function (JobRunner $runner) { $runner->createDelayed('aSubJobName1', function (JobRunner $runner, Job $childJob) { @@ -39,12 +39,12 @@ class RootJobProcessor implements PsrProcessor } } -class SubJobProcessor implements PsrProcessor +class SubJobProcessor implements Processor { /** @var JobRunner */ private $jobRunner; - public function process(PsrMessage $message, PsrContext $context) + public function process(Message $message, Context $context) { $data = JSON::decode($message->getBody()); diff --git a/docs/job_queue/run_unique_job.md b/docs/job_queue/run_unique_job.md index 84078c40c..60803cfaf 100644 --- a/docs/job_queue/run_unique_job.md +++ b/docs/job_queue/run_unique_job.md @@ -12,17 +12,17 @@ It shows how you can run unique job using job queue (The configuration is descri ```php jobRunner->runUnique($message->getMessageId(), 'aJobName', function () { // do your job, there is no any other processes executing same job, diff --git a/docs/laravel/quick_tour.md b/docs/laravel/quick_tour.md index 653367805..e43e9d15e 100644 --- a/docs/laravel/quick_tour.md +++ b/docs/laravel/quick_tour.md @@ -68,14 +68,14 @@ Register processor: ```php resolving(SimpleClient::class, function (SimpleClient $client, $app) { - $client->bindTopic('enqueue_test', function(PsrMessage $message) { + $client->bindTopic('enqueue_test', function(Message $message) { // do stuff here - return PsrProcessor::ACK; + return Processor::ACK; }); return $client; diff --git a/docs/magento/quick_tour.md b/docs/magento/quick_tour.md index 3d23cd565..7ab7bb97f 100644 --- a/docs/magento/quick_tour.md +++ b/docs/magento/quick_tour.md @@ -44,13 +44,13 @@ To consume messages you have to define a processor class first: getBody() -> 'payload' diff --git a/docs/magento2/quick_tour.md b/docs/magento2/quick_tour.md index c6ced2be2..a0813395f 100644 --- a/docs/magento2/quick_tour.md +++ b/docs/magento2/quick_tour.md @@ -53,13 +53,13 @@ To consume messages you have to define a processor class first: namespace Acme\Module\Helper\Async; -use Interop\Queue\PsrContext; -use Interop\Queue\PsrMessage; -use Interop\Queue\PsrProcessor; +use Interop\Queue\Context; +use Interop\Queue\Message; +use Interop\Queue\Processor; -class Foo implements PsrProcessor +class Foo implements Processor { - public function process(PsrMessage $message, PsrContext $context) + public function process(Message $message, Context $context) { // do job // $message->getBody() -> 'payload' diff --git a/docs/monolog/send-messages-to-mq.md b/docs/monolog/send-messages-to-mq.md index 591016711..d79040381 100644 --- a/docs/monolog/send-messages-to-mq.md +++ b/docs/monolog/send-messages-to-mq.md @@ -39,18 +39,18 @@ the consumer may look like this: createContext(); $consumer = new QueueConsumer($context); -$consumer->bindCallback('log', function(PsrMessage $message) { +$consumer->bindCallback('log', function(Message $message) { echo $message->getBody().PHP_EOL; - return PsrProcessor::ACK; + return Processor::ACK; }); $consumer->consume(); diff --git a/docs/quick_tour.md b/docs/quick_tour.md index bc5130792..b44ee2c25 100644 --- a/docs/quick_tour.md +++ b/docs/quick_tour.md @@ -20,32 +20,32 @@ Produce a message: ```php createContext(); +/** @var ConnectionFactory $connectionFactory **/ +$context = $connectionFactory->createContext(); -$destination = $psrContext->createQueue('foo'); +$destination = $context->createQueue('foo'); //$destination = $context->createTopic('foo'); -$message = $psrContext->createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($destination, $message); +$context->createProducer()->send($destination, $message); ``` Consume a message: ```php createContext(); +/** @var ConnectionFactory $connectionFactory **/ +$context = $connectionFactory->createContext(); -$destination = $psrContext->createQueue('foo'); +$destination = $context->createQueue('foo'); //$destination = $context->createTopic('foo'); -$consumer = $psrContext->createConsumer($destination); +$consumer = $context->createConsumer($destination); $message = $consumer->receive(); @@ -64,24 +64,24 @@ The `consume` method starts the consumption process which last as long as it is ```php bindCallback('foo_queue', function(PsrMessage $message) { +$queueConsumer->bindCallback('foo_queue', function(Message $message) { // process message - return PsrProcessor::ACK; + return Processor::ACK; }); -$queueConsumer->bindCallback('bar_queue', function(PsrMessage $message) { +$queueConsumer->bindCallback('bar_queue', function(Message $message) { // process message - return PsrProcessor::ACK; + return Processor::ACK; }); $queueConsumer->consume(); @@ -99,9 +99,9 @@ use Enqueue\Consumption\QueueConsumer; use Enqueue\Consumption\Extension\SignalExtension; use Enqueue\Consumption\Extension\LimitConsumptionTimeExtension; -/** @var \Interop\Queue\PsrContext $psrContext */ +/** @var \Interop\Queue\Context $context */ -$queueConsumer = new QueueConsumer($psrContext, new ChainExtension([ +$queueConsumer = new QueueConsumer($context, new ChainExtension([ new SignalExtension(), new LimitConsumptionTimeExtension(new \DateTime('now + 60 sec')), ])); @@ -116,12 +116,12 @@ You can do several calls asynchronously. This is how you can send a RPC message createQueue('foo'); -$message = $psrContext->createMessage('Hi there!'); +$queue = $context->createQueue('foo'); +$message = $context->createMessage('Hi there!'); -$rpcClient = new RpcClient($psrContext); +$rpcClient = new RpcClient($context); $promise = $rpcClient->callAsync($queue, $message, 1); $replyMessage = $promise->receive(); @@ -132,20 +132,20 @@ It simplifies a server side of RPC. ```php bindCallback('foo', function(PsrMessage $message, PsrContext $context) { +$queueConsumer->bindCallback('foo', function(Message $message, Context $context) { $replyMessage = $context->createMessage('Hello'); return Result::reply($replyMessage); @@ -168,14 +168,14 @@ Here's an example of how you can send and consume **event messages**. ```php bindTopic('a_foo_topic', function(PsrMessage $message) { +$client->bindTopic('a_foo_topic', function(Message $message) { echo $message->getBody().PHP_EOL; // your event processor logic here @@ -194,8 +194,8 @@ and **command messages**: ```php bindCommand('bar_command', function(PsrMessage $message) { +$client->bindCommand('bar_command', function(Message $message) { // your bar command processor logic here }); -$client->bindCommand('baz_reply_command', function(PsrMessage $message, PsrContext $context) { +$client->bindCommand('baz_reply_command', function(Message $message, Context $context) { // your baz reply command processor logic here return Result::reply($context->createMessage('theReplyBody')); @@ -248,13 +248,13 @@ Let's see how you can use consumption one: // app.php use Symfony\Component\Console\Application; -use Interop\Queue\PsrMessage; +use Interop\Queue\Message; use Enqueue\Consumption\QueueConsumer; use Enqueue\Symfony\Consumption\ConsumeMessagesCommand; /** @var QueueConsumer $queueConsumer */ -$queueConsumer->bindCallback('a_queue', function(PsrMessage $message) { +$queueConsumer->bindCallback('a_queue', function(Message $message) { // process message }); diff --git a/docs/transport/amqp.md b/docs/transport/amqp.md index 80845e71a..2ad3bef15 100644 --- a/docs/transport/amqp.md +++ b/docs/transport/amqp.md @@ -61,11 +61,11 @@ $factory = new AmqpConnectionFactory([ 'ssl_key' => '/path/to/key.pem', ]); -$psrContext = $factory->createContext(); +$context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('amqp:')->createContext(); -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('amqp+ext:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('amqp:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('amqp+ext:')->createContext(); ``` ## Declare topic. @@ -76,14 +76,14 @@ Declare topic operation creates a topic on a broker side. createTopic('foo'); +$fooTopic = $context->createTopic('foo'); $fooTopic->setType(AmqpTopic::TYPE_FANOUT); -$psrContext->declareTopic($fooTopic); +$context->declareTopic($fooTopic); // to remove topic use delete topic method -//$psrContext->deleteTopic($fooTopic); +//$context->deleteTopic($fooTopic); ``` ## Declare queue. @@ -94,14 +94,14 @@ Declare queue operation creates a queue on a broker side. createQueue('foo'); +$fooQueue = $context->createQueue('foo'); $fooQueue->addFlag(AmqpQueue::FLAG_DURABLE); -$psrContext->declareQueue($fooQueue); +$context->declareQueue($fooQueue); // to remove topic use delete queue method -//$psrContext->deleteQueue($fooQueue); +//$context->deleteQueue($fooQueue); ``` ## Bind queue to topic @@ -112,51 +112,51 @@ Connects a queue to the topic. So messages from that topic comes to the queue an bind(new AmqpBind($fooTopic, $fooQueue)); +$context->bind(new AmqpBind($fooTopic, $fooQueue)); ``` ## Send message to topic ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Send message to queue ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Send priority message ```php createQueue('foo'); +$fooQueue = $context->createQueue('foo'); $fooQueue->addFlag(AmqpQueue::FLAG_DURABLE); $fooQueue->setArguments(['x-max-priority' => 10]); -$psrContext->declareQueue($fooQueue); +$context->declareQueue($fooQueue); -$message = $psrContext->createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setPriority(5) // the higher priority the sooner a message gets to a consumer // ->send($fooQueue, $message) @@ -167,12 +167,12 @@ $psrContext->createProducer() ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setTimeToLive(60000) // 60 sec // ->send($fooQueue, $message) @@ -189,14 +189,14 @@ The `enqueue/amqp-tools` package provides two RabbitMQ delay strategies, to use createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setDelayStrategy(new RabbitMqDlxDelayStrategy()) ->setDeliveryDelay(5000) // 5 sec @@ -208,10 +208,10 @@ $psrContext->createProducer() ```php createConsumer($fooQueue); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive(); @@ -225,25 +225,25 @@ $consumer->acknowledge($message); ```php createConsumer($fooQueue); -$barConsumer = $psrContext->createConsumer($barQueue); +$fooConsumer = $context->createConsumer($fooQueue); +$barConsumer = $context->createConsumer($barQueue); -$subscriptionConsumer = $psrContext->createSubscriptionConsumer(); -$subscriptionConsumer->subscribe($fooConsumer, function(PsrMessage $message, PsrConsumer $consumer) { +$subscriptionConsumer = $context->createSubscriptionConsumer(); +$subscriptionConsumer->subscribe($fooConsumer, function(Message $message, Consumer $consumer) { // process message $consumer->acknowledge($message); return true; }); -$subscriptionConsumer->subscribe($barConsumer, function(PsrMessage $message, PsrConsumer $consumer) { +$subscriptionConsumer->subscribe($barConsumer, function(Message $message, Consumer $consumer) { // process message $consumer->acknowledge($message); @@ -258,12 +258,12 @@ $subscriptionConsumer->consume(2000); // 2 sec ```php createQueue('aQueue'); +$queue = $context->createQueue('aQueue'); -$psrContext->purgeQueue($queue); +$context->purgeQueue($queue); ``` [back to index](../index.md) diff --git a/docs/transport/amqp_bunny.md b/docs/transport/amqp_bunny.md index c0f68534b..4a88ea7d8 100644 --- a/docs/transport/amqp_bunny.md +++ b/docs/transport/amqp_bunny.md @@ -51,11 +51,11 @@ $factory = new AmqpConnectionFactory([ // same as above but given as DSN string $factory = new AmqpConnectionFactory('amqp://user:pass@example.com:10000/%2f'); -$psrContext = $factory->createContext(); +$context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('amqp:')->createContext(); -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('amqp+bunny:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('amqp:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('amqp+bunny:')->createContext(); ``` ## Declare topic. @@ -66,14 +66,14 @@ Declare topic operation creates a topic on a broker side. createTopic('foo'); +$fooTopic = $context->createTopic('foo'); $fooTopic->setType(AmqpTopic::TYPE_FANOUT); -$psrContext->declareTopic($fooTopic); +$context->declareTopic($fooTopic); // to remove topic use delete topic method -//$psrContext->deleteTopic($fooTopic); +//$context->deleteTopic($fooTopic); ``` ## Declare queue. @@ -84,14 +84,14 @@ Declare queue operation creates a queue on a broker side. createQueue('foo'); +$fooQueue = $context->createQueue('foo'); $fooQueue->addFlag(AmqpQueue::FLAG_DURABLE); -$psrContext->declareQueue($fooQueue); +$context->declareQueue($fooQueue); // to remove topic use delete queue method -//$psrContext->deleteQueue($fooQueue); +//$context->deleteQueue($fooQueue); ``` ## Bind queue to topic @@ -102,35 +102,35 @@ Connects a queue to the topic. So messages from that topic comes to the queue an bind(new AmqpBind($fooTopic, $fooQueue)); +$context->bind(new AmqpBind($fooTopic, $fooQueue)); ``` ## Send message to topic ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Send message to queue ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Send priority message @@ -139,16 +139,16 @@ $psrContext->createProducer()->send($fooQueue, $message); createQueue('foo'); +$fooQueue = $context->createQueue('foo'); $fooQueue->addFlag(AmqpQueue::FLAG_DURABLE); $fooQueue->setArguments(['x-max-priority' => 10]); -$psrContext->declareQueue($fooQueue); +$context->declareQueue($fooQueue); -$message = $psrContext->createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setPriority(5) // the higher priority the sooner a message gets to a consumer // ->send($fooQueue, $message) @@ -159,12 +159,12 @@ $psrContext->createProducer() ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setTimeToLive(60000) // 60 sec // ->send($fooQueue, $message) @@ -181,14 +181,14 @@ The `enqueue/amqp-tools` package provides two RabbitMQ delay strategies, to use createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setDelayStrategy(new RabbitMqDlxDelayStrategy()) ->setDeliveryDelay(5000) // 5 sec @@ -200,10 +200,10 @@ $psrContext->createProducer() ```php createConsumer($fooQueue); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive(); @@ -217,25 +217,25 @@ $consumer->acknowledge($message); ```php createConsumer($fooQueue); -$barConsumer = $psrContext->createConsumer($barQueue); +$fooConsumer = $context->createConsumer($fooQueue); +$barConsumer = $context->createConsumer($barQueue); -$subscriptionConsumer = $psrContext->createSubscriptionConsumer(); -$subscriptionConsumer->subscribe($fooConsumer, function(PsrMessage $message, PsrConsumer $consumer) { +$subscriptionConsumer = $context->createSubscriptionConsumer(); +$subscriptionConsumer->subscribe($fooConsumer, function(Message $message, Consumer $consumer) { // process message $consumer->acknowledge($message); return true; }); -$subscriptionConsumer->subscribe($barConsumer, function(PsrMessage $message, PsrConsumer $consumer) { +$subscriptionConsumer->subscribe($barConsumer, function(Message $message, Consumer $consumer) { // process message $consumer->acknowledge($message); @@ -250,12 +250,12 @@ $subscriptionConsumer->consume(2000); // 2 sec ```php createQueue('aQueue'); +$queue = $context->createQueue('aQueue'); -$psrContext->purgeQueue($queue); +$context->purgeQueue($queue); ``` [back to index](../index.md) \ No newline at end of file diff --git a/docs/transport/amqp_lib.md b/docs/transport/amqp_lib.md index b3e7e055a..57d41eb46 100644 --- a/docs/transport/amqp_lib.md +++ b/docs/transport/amqp_lib.md @@ -59,11 +59,11 @@ $factory = new AmqpConnectionFactory([ 'ssl_key' => '/path/to/key.pem', ]); -$psrContext = $factory->createContext(); +$context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('amqp:')->createContext(); -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('amqp+lib:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('amqp:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('amqp+lib:')->createContext(); ``` ## Declare topic. @@ -74,14 +74,14 @@ Declare topic operation creates a topic on a broker side. createTopic('foo'); +$fooTopic = $context->createTopic('foo'); $fooTopic->setType(AmqpTopic::TYPE_FANOUT); -$psrContext->declareTopic($fooTopic); +$context->declareTopic($fooTopic); // to remove topic use delete topic method -//$psrContext->deleteTopic($fooTopic); +//$context->deleteTopic($fooTopic); ``` ## Declare queue. @@ -92,14 +92,14 @@ Declare queue operation creates a queue on a broker side. createQueue('foo'); +$fooQueue = $context->createQueue('foo'); $fooQueue->addFlag(AmqpQueue::FLAG_DURABLE); -$psrContext->declareQueue($fooQueue); +$context->declareQueue($fooQueue); // to remove topic use delete queue method -//$psrContext->deleteQueue($fooQueue); +//$context->deleteQueue($fooQueue); ``` ## Bind queue to topic @@ -110,35 +110,35 @@ Connects a queue to the topic. So messages from that topic comes to the queue an bind(new AmqpBind($fooTopic, $fooQueue)); +$context->bind(new AmqpBind($fooTopic, $fooQueue)); ``` ## Send message to topic ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Send message to queue ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Send priority message @@ -147,16 +147,16 @@ $psrContext->createProducer()->send($fooQueue, $message); createQueue('foo'); +$fooQueue = $context->createQueue('foo'); $fooQueue->addFlag(AmqpQueue::FLAG_DURABLE); $fooQueue->setArguments(['x-max-priority' => 10]); -$psrContext->declareQueue($fooQueue); +$context->declareQueue($fooQueue); -$message = $psrContext->createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setPriority(5) // the higher priority the sooner a message gets to a consumer // ->send($fooQueue, $message) @@ -167,12 +167,12 @@ $psrContext->createProducer() ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setTimeToLive(60000) // 60 sec // ->send($fooQueue, $message) @@ -189,14 +189,14 @@ The `enqueue/amqp-tools` package provides two RabbitMQ delay strategies, to use createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setDelayStrategy(new RabbitMqDlxDelayStrategy()) ->setDeliveryDelay(5000) // 5 sec @@ -208,10 +208,10 @@ $psrContext->createProducer() ```php createConsumer($fooQueue); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive(); @@ -225,25 +225,25 @@ $consumer->acknowledge($message); ```php createConsumer($fooQueue); -$barConsumer = $psrContext->createConsumer($barQueue); +$fooConsumer = $context->createConsumer($fooQueue); +$barConsumer = $context->createConsumer($barQueue); -$subscriptionConsumer = $psrContext->createSubscriptionConsumer(); -$subscriptionConsumer->subscribe($fooConsumer, function(PsrMessage $message, PsrConsumer $consumer) { +$subscriptionConsumer = $context->createSubscriptionConsumer(); +$subscriptionConsumer->subscribe($fooConsumer, function(Message $message, Consumer $consumer) { // process message $consumer->acknowledge($message); return true; }); -$subscriptionConsumer->subscribe($barConsumer, function(PsrMessage $message, PsrConsumer $consumer) { +$subscriptionConsumer->subscribe($barConsumer, function(Message $message, Consumer $consumer) { // process message $consumer->acknowledge($message); @@ -258,12 +258,12 @@ $subscriptionConsumer->consume(2000); // 2 sec ```php createQueue('aQueue'); +$queue = $context->createQueue('aQueue'); -$psrContext->purgeQueue($queue); +$context->purgeQueue($queue); ``` [back to index](../index.md) \ No newline at end of file diff --git a/docs/transport/dbal.md b/docs/transport/dbal.md index 6e72d7953..1affe2f37 100644 --- a/docs/transport/dbal.md +++ b/docs/transport/dbal.md @@ -32,7 +32,7 @@ $factory = new DbalConnectionFactory('mysql://user:pass@localhost:3306/mqdev'); // connects to localhost $factory = new DbalConnectionFactory('mysql:'); -$psrContext = $factory->createContext(); +$context = $factory->createContext(); ``` * With existing connection: @@ -48,10 +48,10 @@ $factory = new ManagerRegistryConnectionFactory($registry, [ 'connection_name' => 'default', ]); -$psrContext = $factory->createContext(); +$context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('mysql:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('mysql:')->createContext(); ``` ## Init database @@ -61,43 +61,43 @@ Please pay attention to that the database has to be created manually. ```php createDataBaseTable(); +$context->createDataBaseTable(); ``` ## Send message to topic ```php createTopic('aTopic'); -$message = $psrContext->createMessage('Hello world!'); +$fooTopic = $context->createTopic('aTopic'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Send message to queue ```php createQueue('aQueue'); -$message = $psrContext->createMessage('Hello world!'); +$fooQueue = $context->createQueue('aQueue'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Consume message: ```php createQueue('aQueue'); -$consumer = $psrContext->createConsumer($fooQueue); +$fooQueue = $context->createQueue('aQueue'); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive(); @@ -108,25 +108,25 @@ $message = $consumer->receive(); ```php createConsumer($fooQueue); -$barConsumer = $psrContext->createConsumer($barQueue); +$fooConsumer = $context->createConsumer($fooQueue); +$barConsumer = $context->createConsumer($barQueue); -$subscriptionConsumer = $psrContext->createSubscriptionConsumer(); -$subscriptionConsumer->subscribe($fooConsumer, function(PsrMessage $message, PsrConsumer $consumer) { +$subscriptionConsumer = $context->createSubscriptionConsumer(); +$subscriptionConsumer->subscribe($fooConsumer, function(Message $message, Consumer $consumer) { // process message $consumer->acknowledge($message); return true; }); -$subscriptionConsumer->subscribe($barConsumer, function(PsrMessage $message, PsrConsumer $consumer) { +$subscriptionConsumer->subscribe($barConsumer, function(Message $message, Consumer $consumer) { // process message $consumer->acknowledge($message); diff --git a/docs/transport/filesystem.md b/docs/transport/filesystem.md index 02154546f..a57b93e5d 100644 --- a/docs/transport/filesystem.md +++ b/docs/transport/filesystem.md @@ -46,46 +46,46 @@ $connectionFactory = new FsConnectionFactory([ 'pre_fetch_count' => 1, ]); -$psrContext = $connectionFactory->createContext(); +$context = $connectionFactory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('file:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('file:')->createContext(); ``` ## Send message to topic ```php createTopic('aTopic'); -$message = $psrContext->createMessage('Hello world!'); +$fooTopic = $context->createTopic('aTopic'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Send message to queue ```php createQueue('aQueue'); -$message = $psrContext->createMessage('Hello world!'); +$fooQueue = $context->createQueue('aQueue'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Send expiration message ```php createQueue('aQueue'); -$message = $psrContext->createMessage('Hello world!'); +$fooQueue = $context->createQueue('aQueue'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setTimeToLive(60000) // 60 sec // ->send($fooQueue, $message) @@ -96,10 +96,10 @@ $psrContext->createProducer() ```php createQueue('aQueue'); -$consumer = $psrContext->createConsumer($fooQueue); +$fooQueue = $context->createQueue('aQueue'); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive(); @@ -113,11 +113,11 @@ $consumer->acknowledge($message); ```php createQueue('aQueue'); +$fooQueue = $context->createQueue('aQueue'); -$psrContext->purge($fooQueue); +$context->purge($fooQueue); ``` [back to index](../index.md) \ No newline at end of file diff --git a/docs/transport/gearman.md b/docs/transport/gearman.md index 1baca30e0..75ec50b3d 100644 --- a/docs/transport/gearman.md +++ b/docs/transport/gearman.md @@ -37,44 +37,44 @@ $factory = new GearmanConnectionFactory([ 'port' => 5555 ]); -$psrContext = $factory->createContext(); +$context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('gearman:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('gearman:')->createContext(); ``` ## Send message to topic ```php createTopic('aTopic'); -$message = $psrContext->createMessage('Hello world!'); +$fooTopic = $context->createTopic('aTopic'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Send message to queue ```php createQueue('aQueue'); -$message = $psrContext->createMessage('Hello world!'); +$fooQueue = $context->createQueue('aQueue'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Consume message: ```php createQueue('aQueue'); -$consumer = $psrContext->createConsumer($fooQueue); +$fooQueue = $context->createQueue('aQueue'); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive(2000); // wait for 2 seconds diff --git a/docs/transport/gps.md b/docs/transport/gps.md index 86269f9c5..ceaa76828 100644 --- a/docs/transport/gps.md +++ b/docs/transport/gps.md @@ -30,10 +30,10 @@ $connectionFactory = new GpsConnectionFactory(); // save as above $connectionFactory = new GpsConnectionFactory('gps:'); -$psrContext = $connectionFactory->createContext(); +$context = $connectionFactory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('gps:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('gps:')->createContext(); ``` ## Send message to topic @@ -44,14 +44,14 @@ Google allows messages to be sent only to topic. ```php createTopic('foo'); -$message = $psrContext->createMessage('Hello world!'); +$fooTopic = $context->createTopic('foo'); +$message = $context->createMessage('Hello world!'); -$psrContext->declareTopic($fooTopic); +$context->declareTopic($fooTopic); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Consume message: @@ -61,14 +61,14 @@ Google does not allow consuming message from the topic directly. ```php createTopic('foo'); -$fooQueue = $psrContext->createQueue('foo'); +$fooTopic = $context->createTopic('foo'); +$fooQueue = $context->createQueue('foo'); -$psrContext->subscribe($fooTopic, $fooQueue); +$context->subscribe($fooTopic, $fooQueue); -$consumer = $psrContext->createConsumer($fooQueue); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive(); // process a message diff --git a/docs/transport/kafka.md b/docs/transport/kafka.md index b2bb92e09..e11fc1163 100644 --- a/docs/transport/kafka.md +++ b/docs/transport/kafka.md @@ -43,47 +43,47 @@ $connectionFactory = new RdKafkaConnectionFactory([ ], ]); -$psrContext = $connectionFactory->createContext(); +$context = $connectionFactory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('kafka:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('kafka:')->createContext(); ``` ## Send message to topic ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$fooTopic = $psrContext->createTopic('foo'); +$fooTopic = $context->createTopic('foo'); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Send message to queue ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$fooQueue = $psrContext->createQueue('foo'); +$fooQueue = $context->createQueue('foo'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Consume message: ```php createQueue('foo'); +$fooQueue = $context->createQueue('foo'); -$consumer = $psrContext->createConsumer($fooQueue); +$consumer = $context->createConsumer($fooQueue); // Enable async commit to gain better performance. //$consumer->setCommitAsync(true); @@ -114,9 +114,9 @@ class FooSerializer implements Serializer public function toString(RdKafkaMessage $message) {} } -/** @var \Enqueue\RdKafka\RdKafkaContext $psrContext */ +/** @var \Enqueue\RdKafka\RdKafkaContext $context */ -$psrContext->setSerializer(new FooSerializer()); +$context->setSerializer(new FooSerializer()); ``` ## Change offset @@ -126,11 +126,11 @@ There is an ability to change the current offset. ```php createQueue('foo'); +$fooQueue = $context->createQueue('foo'); -$consumer = $psrContext->createConsumer($fooQueue); +$consumer = $context->createConsumer($fooQueue); $consumer->setOffset(123); $message = $consumer->receive(2000); diff --git a/docs/transport/mongodb.md b/docs/transport/mongodb.md index 610580478..95f19490e 100644 --- a/docs/transport/mongodb.md +++ b/docs/transport/mongodb.md @@ -40,47 +40,47 @@ $factory = new MongodbConnectionFactory([ 'polling_interval' => '1000', ]); -$psrContext = $factory->createContext(); +$context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('mongodb:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('mongodb:')->createContext(); ``` ## Send message to topic ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Send message to queue ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Send priority message ```php createQueue('foo'); +$fooQueue = $context->createQueue('foo'); -$message = $psrContext->createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setPriority(5) // the higher priority the sooner a message gets to a consumer // ->send($fooQueue, $message) @@ -91,12 +91,12 @@ $psrContext->createProducer() ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setTimeToLive(60000) // 60 sec // ->send($fooQueue, $message) @@ -109,14 +109,14 @@ $psrContext->createProducer() createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setDeliveryDelay(5000) // 5 sec ->send($fooQueue, $message) @@ -127,10 +127,10 @@ $psrContext->createProducer() ```php createConsumer($fooQueue); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive(); @@ -144,25 +144,25 @@ $consumer->acknowledge($message); ```php createConsumer($fooQueue); -$barConsumer = $psrContext->createConsumer($barQueue); +$fooConsumer = $context->createConsumer($fooQueue); +$barConsumer = $context->createConsumer($barQueue); -$subscriptionConsumer = $psrContext->createSubscriptionConsumer(); -$subscriptionConsumer->subscribe($fooConsumer, function(PsrMessage $message, PsrConsumer $consumer) { +$subscriptionConsumer = $context->createSubscriptionConsumer(); +$subscriptionConsumer->subscribe($fooConsumer, function(Message $message, Consumer $consumer) { // process message $consumer->acknowledge($message); return true; }); -$subscriptionConsumer->subscribe($barConsumer, function(PsrMessage $message, PsrConsumer $consumer) { +$subscriptionConsumer->subscribe($barConsumer, function(Message $message, Consumer $consumer) { // process message $consumer->acknowledge($message); diff --git a/docs/transport/null.md b/docs/transport/null.md index 0a30244ea..f1aef17ef 100644 --- a/docs/transport/null.md +++ b/docs/transport/null.md @@ -21,7 +21,7 @@ use Enqueue\Null\NullConnectionFactory; $connectionFactory = new NullConnectionFactory(); -$psrContext = $connectionFactory->createContext(); +$context = $connectionFactory->createContext(); ``` [back to index](../index.md) \ No newline at end of file diff --git a/docs/transport/pheanstalk.md b/docs/transport/pheanstalk.md index e0ee49b8b..7da46f9ff 100644 --- a/docs/transport/pheanstalk.md +++ b/docs/transport/pheanstalk.md @@ -37,44 +37,44 @@ $factory = new PheanstalkConnectionFactory([ 'port' => 5555 ]); -$psrContext = $factory->createContext(); +$context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('beanstalk:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('beanstalk:')->createContext(); ``` ## Send message to topic ```php createTopic('aTopic'); -$message = $psrContext->createMessage('Hello world!'); +$fooTopic = $context->createTopic('aTopic'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Send message to queue ```php createQueue('aQueue'); -$message = $psrContext->createMessage('Hello world!'); +$fooQueue = $context->createQueue('aQueue'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Consume message: ```php createQueue('aQueue'); -$consumer = $psrContext->createConsumer($fooQueue); +$fooQueue = $context->createQueue('aQueue'); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive(2000); // wait for 2 seconds diff --git a/docs/transport/redis.md b/docs/transport/redis.md index ff5a45990..5cbb7e137 100644 --- a/docs/transport/redis.md +++ b/docs/transport/redis.md @@ -58,10 +58,10 @@ $factory = new RedisConnectionFactory([ // same as above but given as DSN string $factory = new RedisConnectionFactory('redis+phpredis://example.com:1000'); -$psrContext = $factory->createContext(); +$context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('redis:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('redis:')->createContext(); // pass redis instance directly $redis = new \Enqueue\Redis\PhpRedis([ /** redis connection options */ ]); @@ -85,7 +85,7 @@ $connectionFactory = new RedisConnectionFactory([ 'scheme_extensions' => 'predis', ]); -$psrContext = $connectionFactory->createContext(); +$context = $connectionFactory->createContext(); ``` * With custom redis instance: @@ -109,36 +109,36 @@ $factory = new RedisConnectionFactory($redis); ```php createTopic('aTopic'); -$message = $psrContext->createMessage('Hello world!'); +$fooTopic = $context->createTopic('aTopic'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Send message to queue ```php createQueue('aQueue'); -$message = $psrContext->createMessage('Hello world!'); +$fooQueue = $context->createQueue('aQueue'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Send expiration message ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setTimeToLive(60000) // 60 sec // ->send($fooQueue, $message) @@ -149,12 +149,12 @@ $psrContext->createProducer() ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setDeliveryDelay(5000) // 5 sec ->send($fooQueue, $message) @@ -165,10 +165,10 @@ $psrContext->createProducer() ```php createQueue('aQueue'); -$consumer = $psrContext->createConsumer($fooQueue); +$fooQueue = $context->createQueue('aQueue'); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive(); @@ -182,22 +182,22 @@ $consumer->acknowledge($message); ```php createQueue('aQueue'); +$fooQueue = $context->createQueue('aQueue'); -$psrContext->deleteQueue($fooQueue); +$context->deleteQueue($fooQueue); ``` ## Delete topic (purge messages): ```php createTopic('aTopic'); +$fooTopic = $context->createTopic('aTopic'); -$psrContext->deleteTopic($fooTopic); +$context->deleteTopic($fooTopic); ``` ## Connect Heroku Redis diff --git a/docs/transport/sqs.md b/docs/transport/sqs.md index 01ecc698d..ca6e1cb48 100644 --- a/docs/transport/sqs.md +++ b/docs/transport/sqs.md @@ -32,14 +32,14 @@ $factory = new SqsConnectionFactory([ // same as above but given as DSN string. You may need to url encode secret if it contains special char (like +) $factory = new SqsConnectionFactory('sqs:?key=aKey&secret=aSecret®ion=aRegion'); -$psrContext = $factory->createContext(); +$context = $factory->createContext(); // using a pre-configured client $client = new Aws\Sqs\SqsClient([ /* ... */ ]); $factory = new SqsConnectionFactory($client); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('sqs:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('sqs:')->createContext(); ``` ## Declare queue. @@ -48,37 +48,37 @@ Declare queue operation creates a queue on a broker side. ```php createQueue('foo'); -$psrContext->declareQueue($fooQueue); +$fooQueue = $context->createQueue('foo'); +$context->declareQueue($fooQueue); // to remove queue use deleteQueue method -//$psrContext->deleteQueue($fooQueue); +//$context->deleteQueue($fooQueue); ``` ## Send message to queue ```php createQueue('foo'); -$message = $psrContext->createMessage('Hello world!'); +$fooQueue = $context->createQueue('foo'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Send delay message ```php createQueue('foo'); -$message = $psrContext->createMessage('Hello world!'); +$fooQueue = $context->createQueue('foo'); +$message = $context->createMessage('Hello world!'); -$psrContext->createProducer() +$context->createProducer() ->setDeliveryDelay(60000) // 60 sec ->send($fooQueue, $message) @@ -89,10 +89,10 @@ $psrContext->createProducer() ```php createQueue('foo'); -$consumer = $psrContext->createConsumer($fooQueue); +$fooQueue = $context->createQueue('foo'); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive(); @@ -106,11 +106,11 @@ $consumer->acknowledge($message); ```php createQueue('foo'); +$fooQueue = $context->createQueue('foo'); -$psrContext->purgeQueue($fooQueue); +$context->purgeQueue($fooQueue); ``` [back to index](../index.md) diff --git a/docs/transport/stomp.md b/docs/transport/stomp.md index 251d6b135..a3889b8dd 100644 --- a/docs/transport/stomp.md +++ b/docs/transport/stomp.md @@ -37,47 +37,47 @@ $factory = new StompConnectionFactory([ // same as above but given as DSN string $factory = new StompConnectionFactory('stomp://example.com:1000?login=theLogin'); -$psrContext = $factory->createContext(); +$context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN -$psrContext = (new \Enqueue\ConnectionFactoryFactory())->create('stomp:')->createContext(); +$context = (new \Enqueue\ConnectionFactoryFactory())->create('stomp:')->createContext(); ``` ## Send message to topic ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$fooTopic = $psrContext->createTopic('foo'); +$fooTopic = $context->createTopic('foo'); -$psrContext->createProducer()->send($fooTopic, $message); +$context->createProducer()->send($fooTopic, $message); ``` ## Send message to queue ```php createMessage('Hello world!'); +$message = $context->createMessage('Hello world!'); -$fooQueue = $psrContext->createQueue('foo'); +$fooQueue = $context->createQueue('foo'); -$psrContext->createProducer()->send($fooQueue, $message); +$context->createProducer()->send($fooQueue, $message); ``` ## Consume message: ```php createQueue('foo'); +$fooQueue = $context->createQueue('foo'); -$consumer = $psrContext->createConsumer($fooQueue); +$consumer = $context->createConsumer($fooQueue); $message = $consumer->receive();