Skip to content

Commit 4a78c2e

Browse files
authored
Merge pull request #1301 from eortiz-tracktik/issue-940
fix: do not reset attemps header when message is requeue
2 parents 261409d + dd01502 commit 4a78c2e

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

pkg/redis/RedisConsumer.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ public function getRedeliveryDelay(): ?int
4242
return $this->redeliveryDelay;
4343
}
4444

45-
/**
46-
* @param int $delay
47-
*/
4845
public function setRedeliveryDelay(int $delay): void
4946
{
5047
$this->redeliveryDelay = $delay;
@@ -103,7 +100,7 @@ public function reject(Message $message, bool $requeue = false): void
103100

104101
if ($requeue) {
105102
$message = $this->getContext()->getSerializer()->toMessage($message->getReservedKey());
106-
$message->setHeader('attempts', 0);
103+
$message->setRedelivered(true);
107104

108105
if ($message->getTimeToLive()) {
109106
$message->setHeader('expires_at', time() + $message->getTimeToLive());

pkg/redis/Tests/RedisConnectionFactoryConfigTest.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public static function provideConfigs()
195195
],
196196
];
197197

198-
//check normal redis connection for php redis extension
198+
// check normal redis connection for php redis extension
199199
yield [
200200
'redis+phpredis://localhost:1234?foo=bar',
201201
[
@@ -218,7 +218,7 @@ public static function provideConfigs()
218218
],
219219
];
220220

221-
//check normal redis connection for predis library
221+
// check normal redis connection for predis library
222222
yield [
223223
'redis+predis://localhost:1234?foo=bar',
224224
[
@@ -241,7 +241,7 @@ public static function provideConfigs()
241241
],
242242
];
243243

244-
//check tls connection for predis library
244+
// check tls connection for predis library
245245
yield [
246246
'rediss+predis://localhost:1234?foo=bar&async=1',
247247
[
@@ -264,11 +264,11 @@ public static function provideConfigs()
264264
],
265265
];
266266

267-
//check tls connection for predis library
267+
// check tls connection for predis library
268268
yield [
269269
'rediss+phpredis://localhost:1234?foo=bar&async=1',
270270
[
271-
'host' => 'tls://localhost',
271+
'host' => 'localhost',
272272
'scheme' => 'rediss',
273273
'port' => 1234,
274274
'timeout' => 5.,
@@ -376,7 +376,6 @@ public static function provideConfigs()
376376
];
377377

378378
// from predis doc
379-
380379
yield [
381380
'tls://127.0.0.1?ssl[cafile]=private.pem&ssl[verify_peer]=1',
382381
[

pkg/redis/Tests/RedisConsumerTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public function testShouldSendSameMessageToDestinationOnReQueue()
112112

113113
$message = new RedisMessage();
114114
$message->setBody('text');
115+
$message->setHeader('attempts', 0);
115116
$message->setReservedKey($serializer->toString($message));
116117

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

0 commit comments

Comments
 (0)