Skip to content

fix: do not reset attemps header when message is requeue #1301

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
May 20, 2023
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
5 changes: 1 addition & 4 deletions pkg/redis/RedisConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ public function getRedeliveryDelay(): ?int
return $this->redeliveryDelay;
}

/**
* @param int $delay
*/
public function setRedeliveryDelay(int $delay): void
{
$this->redeliveryDelay = $delay;
Expand Down Expand Up @@ -103,7 +100,7 @@ public function reject(Message $message, bool $requeue = false): void

if ($requeue) {
$message = $this->getContext()->getSerializer()->toMessage($message->getReservedKey());
$message->setHeader('attempts', 0);
$message->setRedelivered(true);

if ($message->getTimeToLive()) {
$message->setHeader('expires_at', time() + $message->getTimeToLive());
Expand Down
11 changes: 5 additions & 6 deletions pkg/redis/Tests/RedisConnectionFactoryConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static function provideConfigs()
],
];

//check normal redis connection for php redis extension
// check normal redis connection for php redis extension
yield [
'redis+phpredis://localhost:1234?foo=bar',
[
Expand All @@ -218,7 +218,7 @@ public static function provideConfigs()
],
];

//check normal redis connection for predis library
// check normal redis connection for predis library
yield [
'redis+predis://localhost:1234?foo=bar',
[
Expand All @@ -241,7 +241,7 @@ public static function provideConfigs()
],
];

//check tls connection for predis library
// check tls connection for predis library
yield [
'rediss+predis://localhost:1234?foo=bar&async=1',
[
Expand All @@ -264,11 +264,11 @@ public static function provideConfigs()
],
];

//check tls connection for predis library
// check tls connection for predis library
yield [
'rediss+phpredis://localhost:1234?foo=bar&async=1',
[
'host' => 'tls://localhost',
'host' => 'localhost',
'scheme' => 'rediss',
'port' => 1234,
'timeout' => 5.,
Expand Down Expand Up @@ -376,7 +376,6 @@ public static function provideConfigs()
];

// from predis doc

yield [
'tls://127.0.0.1?ssl[cafile]=private.pem&ssl[verify_peer]=1',
[
Expand Down
1 change: 1 addition & 0 deletions pkg/redis/Tests/RedisConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function testShouldSendSameMessageToDestinationOnReQueue()

$message = new RedisMessage();
$message->setBody('text');
$message->setHeader('attempts', 0);
$message->setReservedKey($serializer->toString($message));

$consumer = new RedisConsumer($contextMock, new RedisDestination('aQueue'));
Expand Down