From 1532cbca162936d29583fffb88bdfddd39a4d5ae Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Thu, 17 Jan 2019 16:16:53 +0000 Subject: [PATCH] Add option to pass the consumer tag --- README.md | 3 ++- composer.json | 2 +- composer.lock | 29 +++++++++++++++-------------- src/Connector/RabbitMQ.php | 7 ++++--- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index e315e6c..f648126 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,8 @@ We've bundled the queues in docker so you should be able to run examples locally |---|---|---|---| | blockingConsumer | Whether the consume method should block execution or only process 1 message | true | true/false | | prefetchSize | Get the limit of messages that can be consumed by the channel | null | any numeric value | -| prefetchCount | The limit of messages that we fetch from the queue | 1 | any numeric value| +| prefetchCount | The limit of messages that we fetch from the queue | 1 | any numeric value | +| consumerTag | A tag for the consumer | default.consumer.tag | any value | ### SQS diff --git a/composer.json b/composer.json index 95633e6..af82722 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "mockery/mockery": "^1.2", "jakub-onderka/php-parallel-lint": "^1.0", "phpro/grumphp": "^0.14", - "sensiolabs/security-checker": "^4.1", + "sensiolabs/security-checker": "^5.0", "nikic/php-parser": "^4.0", "povils/phpmnd": "^2.0", "squizlabs/php_codesniffer": "^3.4" diff --git a/composer.lock b/composer.lock index 1d1405c..2816b0e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "840eefa580fe2779de7447b6a408227d", + "content-hash": "6c71739d71c466b1ef0aacd34b678c5a", "packages": [ { "name": "aws/aws-sdk-php", - "version": "3.85.2", + "version": "3.86.0", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "c113c8008dedb257d1f47770aab1963acf4be092" + "reference": "971494dfc1ef63aaffc7e909936d19140bef9ad6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/c113c8008dedb257d1f47770aab1963acf4be092", - "reference": "c113c8008dedb257d1f47770aab1963acf4be092", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/971494dfc1ef63aaffc7e909936d19140bef9ad6", + "reference": "971494dfc1ef63aaffc7e909936d19140bef9ad6", "shasum": "" }, "require": { @@ -87,7 +87,7 @@ "s3", "sdk" ], - "time": "2019-01-14T23:06:17+00:00" + "time": "2019-01-16T18:53:53+00:00" }, { "name": "guzzlehttp/guzzle", @@ -3022,20 +3022,21 @@ }, { "name": "sensiolabs/security-checker", - "version": "v4.1.8", + "version": "v5.0.3", "source": { "type": "git", "url": "https://github.com/sensiolabs/security-checker.git", - "reference": "dc270d5fec418cc6ac983671dba5d80ffaffb142" + "reference": "46be3f58adac13084497961e10eed9a7fb4d44d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sensiolabs/security-checker/zipball/dc270d5fec418cc6ac983671dba5d80ffaffb142", - "reference": "dc270d5fec418cc6ac983671dba5d80ffaffb142", + "url": "https://api.github.com/repos/sensiolabs/security-checker/zipball/46be3f58adac13084497961e10eed9a7fb4d44d1", + "reference": "46be3f58adac13084497961e10eed9a7fb4d44d1", "shasum": "" }, "require": { "composer/ca-bundle": "^1.0", + "php": ">=5.5.9", "symfony/console": "~2.7|~3.0|~4.0" }, "bin": [ @@ -3044,12 +3045,12 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "5.0-dev" } }, "autoload": { - "psr-0": { - "SensioLabs\\Security": "" + "psr-4": { + "SensioLabs\\Security\\": "SensioLabs/Security" } }, "notification-url": "https://packagist.org/downloads/", @@ -3063,7 +3064,7 @@ } ], "description": "A security checker for your composer.lock", - "time": "2018-02-28T22:10:01+00:00" + "time": "2018-12-19T17:14:59+00:00" }, { "name": "squizlabs/php_codesniffer", diff --git a/src/Connector/RabbitMQ.php b/src/Connector/RabbitMQ.php index 7aa093c..3d95711 100644 --- a/src/Connector/RabbitMQ.php +++ b/src/Connector/RabbitMQ.php @@ -14,7 +14,7 @@ final class RabbitMQ extends AMQPLazyConnection implements QueueInterface { - private const CONSUMER_TAG = '.consumer.tag'; + private const CONSUMER_TAG = 'default.consumer.tag'; private const DEFAULT_PREFETCH_SIZE = null; @@ -32,7 +32,8 @@ final class RabbitMQ extends AMQPLazyConnection implements QueueInterface private $queueOptions = [ 'blockingConsumer' => true, 'prefetchSize' => self::DEFAULT_PREFETCH_SIZE, - 'prefetchCount' => self::PREFETCH_COUNT + 'prefetchCount' => self::PREFETCH_COUNT, + 'consumerTag' => self::CONSUMER_TAG ]; public function queueMessage(string $queue, array $message): void @@ -57,7 +58,7 @@ public function consume(string $queue, callable $callback, callable $idleCallbac $this->channel->basic_consume( $queue, - $queue . self::CONSUMER_TAG, + $this->queueOptions['consumerTag'], false, false, false,