Skip to content
Permalink
Browse files

bug #31396 [Messenger] Fix rejecting of pending messages (alexander-s…

…chranz)

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: antirez/redis#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
  • Loading branch information...
fabpot committed May 6, 2019
2 parents ecfccc6 + 072e466 commit bec45edbea90fc5f4c207fc34f9198d2347263c7
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php
@@ -89,7 +89,7 @@ public function get(): ?array
} catch (\RedisException $e) {
}
if ($e || (false === $messages && !$this->couldHavePendingMessages)) {
if ($e || false === $messages) {
throw new TransportException(
($e ? $e->getMessage() : $this->connection->getLastError()) ?? 'Could not read messages from the redis stream.'
);
@@ -132,7 +132,8 @@ public function reject(string $id): void
{
$e = null;
try {
$deleted = $this->connection->xdel($this->stream, [$id]);
$deleted = $this->connection->xack($this->stream, $this->group, [$id]);
$deleted = $this->connection->xdel($this->stream, [$id]) && $deleted;
} catch (\RedisException $e) {
}

0 comments on commit bec45ed

Please sign in to comment.
You can’t perform that action at this time.