From cf976e7515c22203743e9635c9cb8ec85e1ed037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Dronga?= Date: Thu, 6 Oct 2022 13:52:42 +0300 Subject: [PATCH] replace amqp-lib deprecated public property with getters --- pkg/amqp-lib/AmqpContext.php | 6 +++--- pkg/amqp-lib/AmqpSubscriptionConsumer.php | 4 ++-- pkg/amqp-lib/Tests/AmqpConsumerTest.php | 9 ++------- pkg/amqp-lib/composer.json | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/pkg/amqp-lib/AmqpContext.php b/pkg/amqp-lib/AmqpContext.php index 32f60c21b..34569659d 100644 --- a/pkg/amqp-lib/AmqpContext.php +++ b/pkg/amqp-lib/AmqpContext.php @@ -309,9 +309,9 @@ public function convertMessage(LibAMQPMessage $amqpMessage): InteropAmqpMessage unset($headers['application_headers']); $message = new AmqpMessage($amqpMessage->getBody(), $properties, $headers); - $message->setDeliveryTag((int) $amqpMessage->delivery_info['delivery_tag']); - $message->setRedelivered($amqpMessage->delivery_info['redelivered']); - $message->setRoutingKey($amqpMessage->delivery_info['routing_key']); + $message->setDeliveryTag((int) $amqpMessage->getDeliveryTag()); + $message->setRedelivered($amqpMessage->isRedelivered()); + $message->setRoutingKey($amqpMessage->getRoutingKey()); return $message; } diff --git a/pkg/amqp-lib/AmqpSubscriptionConsumer.php b/pkg/amqp-lib/AmqpSubscriptionConsumer.php index e70b61a24..5d59ddf82 100644 --- a/pkg/amqp-lib/AmqpSubscriptionConsumer.php +++ b/pkg/amqp-lib/AmqpSubscriptionConsumer.php @@ -102,13 +102,13 @@ public function subscribe(Consumer $consumer, callable $callback): void $libCallback = function (LibAMQPMessage $message) { $receivedMessage = $this->context->convertMessage($message); - $receivedMessage->setConsumerTag($message->delivery_info['consumer_tag']); + $receivedMessage->setConsumerTag($message->getConsumerTag()); /** * @var AmqpConsumer * @var callable $callback */ - list($consumer, $callback) = $this->subscribers[$message->delivery_info['consumer_tag']]; + list($consumer, $callback) = $this->subscribers[$message->getConsumerTag()]; if (false === call_user_func($callback, $receivedMessage, $consumer)) { throw new StopBasicConsumptionException(); diff --git a/pkg/amqp-lib/Tests/AmqpConsumerTest.php b/pkg/amqp-lib/Tests/AmqpConsumerTest.php index 2bd637d94..3961e1ab9 100644 --- a/pkg/amqp-lib/Tests/AmqpConsumerTest.php +++ b/pkg/amqp-lib/Tests/AmqpConsumerTest.php @@ -115,10 +115,7 @@ public function testOnRejectShouldRejectMessage() public function testShouldReturnMessageOnReceiveNoWait() { $libMessage = new \PhpAmqpLib\Message\AMQPMessage('body'); - $libMessage->delivery_info['delivery_tag'] = 'delivery-tag'; - $libMessage->delivery_info['routing_key'] = 'routing-key'; - $libMessage->delivery_info['redelivered'] = true; - $libMessage->delivery_info['routing_key'] = 'routing-key'; + $libMessage->setDeliveryInfo('delivery-tag', true, '', 'routing-key'); $message = new AmqpMessage(); @@ -152,9 +149,7 @@ public function testShouldReturnMessageOnReceiveNoWait() public function testShouldReturnMessageOnReceiveWithReceiveMethodBasicGet() { $libMessage = new \PhpAmqpLib\Message\AMQPMessage('body'); - $libMessage->delivery_info['delivery_tag'] = 'delivery-tag'; - $libMessage->delivery_info['routing_key'] = 'routing-key'; - $libMessage->delivery_info['redelivered'] = true; + $libMessage->setDeliveryInfo('delivery-tag', true, '', 'routing-key'); $message = new AmqpMessage(); diff --git a/pkg/amqp-lib/composer.json b/pkg/amqp-lib/composer.json index 9665a2cca..3f66bf7b3 100644 --- a/pkg/amqp-lib/composer.json +++ b/pkg/amqp-lib/composer.json @@ -7,7 +7,7 @@ "license": "MIT", "require": { "php": "^7.3|^8.0", - "php-amqplib/php-amqplib": "^3.0", + "php-amqplib/php-amqplib": "^3.2", "queue-interop/amqp-interop": "^0.8.2", "queue-interop/queue-interop": "^0.8", "enqueue/amqp-tools": "^0.10"