Skip to content

[amqp-lib] Replace amqp-lib deprecated public property with getters #1273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/amqp-lib/AmqpContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/amqp-lib/AmqpSubscriptionConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 2 additions & 7 deletions pkg/amqp-lib/Tests/AmqpConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion pkg/amqp-lib/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down