Skip to content

DBalConsumer reject with requeue wrong logic #1396

Description

@gboor

I just ran into this problem where a message that could not be processed and was rejected with requeue true just kept being processed (and not passing) over and over.

After looking at the DBalConsumer reject code, it seems to be entirely logically wrong;

    public function reject(Message $message, bool $requeue = false): void
    {
        InvalidMessageException::assertMessageInstanceOf($message, DbalMessage::class);

        if ($requeue) {
            $message = clone $message;
            $message->setRedelivered(false);

            $this->getContext()->createProducer()->send($this->queue, $message);
        }

        $this->acknowledge($message);
    }

What this does is clone the message as-is, specifically set redelivered to false instead of true (which one would expect), doesn't add any delays, even though the redeliveryDelay is configured, but never used.

It would seem to me that the logic here is very wrong. I would expect it to set redelivered to true and add the redeliverDelay and then just update the message.

I also don't get why it has to be cloned and then acknowledged, but that may be an adapter oddity.

Am I correct in my assumption that this is faulty logic, or is there a reason it works this way that I'm not clear on?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions