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

Skip to content

Commit bec45ed

Browse files
committed
bug #31396 [Messenger] Fix rejecting of pending messages (alexander-schranz)
This PR was squashed before being merged into the 4.3-dev branch (closes #31396). Discussion ---------- [Messenger] Fix rejecting of pending messages | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #... | License | MIT | Doc PR | - As discussed in #31387 (comment). It seems pending messages are not removed by calling xdel so we need to call xack first to remove them from the pending state and then call xdel to remove it from the complete stream. It seems to be the correct way as mentioned in: https://github.com/antirez/redis/issues/5754 Test should be the same as added in: https://github.com/symfony/symfony/pull/31387/files#diff-46c1e03dafbcebc46b5cace7d05de20c Commits ------- 072e466 [Messenger] Fix rejecting of pending messages
2 parents ecfccc6 + 072e466 commit bec45ed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function get(): ?array
8989
} catch (\RedisException $e) {
9090
}
9191

92-
if ($e || (false === $messages && !$this->couldHavePendingMessages)) {
92+
if ($e || false === $messages) {
9393
throw new TransportException(
9494
($e ? $e->getMessage() : $this->connection->getLastError()) ?? 'Could not read messages from the redis stream.'
9595
);
@@ -132,7 +132,8 @@ public function reject(string $id): void
132132
{
133133
$e = null;
134134
try {
135-
$deleted = $this->connection->xdel($this->stream, [$id]);
135+
$deleted = $this->connection->xack($this->stream, $this->group, [$id]);
136+
$deleted = $this->connection->xdel($this->stream, [$id]) && $deleted;
136137
} catch (\RedisException $e) {
137138
}
138139

0 commit comments

Comments
 (0)