Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf338e7

Browse files
committed
Fixing bug where attempts never incremented
1 parent c92c2fd commit bf338e7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,21 @@ public function publishForRetry(\AMQPEnvelope $message)
191191

192192
// increment the number of attempts
193193
$attemptNumber = ((int) $message->getHeader(self::ATTEMPT_COUNT_HEADER_NAME) ?: 0);
194-
++$attemptNumber;
194+
$attemptNumber++;
195195

196196
// only allow the attemptNumber to go as high as the configure
197197
// this will avoid unnecessary queues from being created
198198
$configuredRetryTtlCount = isset($retryConfiguration['ttl']) ? \count($retryConfiguration['ttl']) - 1 : 0;
199-
if ($attemptNumber > $configuredRetryTtlCount) {
200-
$attemptNumber = $configuredRetryTtlCount;
199+
$attemptNumberForTtl = $attemptNumber;
200+
if ($attemptNumberForTtl > $configuredRetryTtlCount) {
201+
$attemptNumberForTtl = $configuredRetryTtlCount;
201202
}
202203

203204
if ($this->shouldSetup()) {
204-
$this->setupRetry($retryConfiguration, $attemptNumber);
205+
$this->setupRetry($retryConfiguration, $attemptNumberForTtl);
205206
}
206207

207-
$routingKey = str_replace('%attempt%', $attemptNumber, $retryConfiguration['routing_key_pattern']);
208+
$routingKey = str_replace('%attempt%', $attemptNumberForTtl, $retryConfiguration['routing_key_pattern']);
208209
$flags = $this->queueConfiguration['flags'] ?? AMQP_NOPARAM;
209210
$headers = $message->getHeaders();
210211
$headers[self::ATTEMPT_COUNT_HEADER_NAME] = $attemptNumber;

0 commit comments

Comments
 (0)