Skip to content

Implement ListableReceiverInterface in AmazonSqsTransport #38639

@jacekwilczynski

Description

@jacekwilczynski

Description
I would like to be able to peek at a few failed messages using the messenger:failed:show command but can't because \Symfony\Component\Messenger\Bridge\AmazonSqs\Transport\AmazonSqsTransport does not implement \Symfony\Component\Messenger\Transport\Receiver\ListableReceiverInterface.

Amazon SQS has a receiveMessage endpoint but it does not allow free listing or searching through messages, it can only return up to 10 oldest messages, without pagination. Therefore, the only options are:

  1. traversing the queue by taking items off and then putting them back at the end
  2. not bothering with getting more than 10 items

Option 1 is quite hacky and would interfere with other processes trying to access the queue so I wouldn't do it. Option 2 is only a partial implementation of the interface but would still be useful.

I can write the implementation but I'd like to get approval on the ticket first.

Example

class AmazonSqsReceiver implements /*...*/ ListableReceiverInterface
{
    private const MAX_RECEIVE_MESSAGES = 10;

    /*...*/

    public function all($limit = self::MAX_RECEIVE_MESSAGES): iterable
    {
        return $this->connection->peek($limit); // Would need to add a method like that, sending requests to the receiveMessage endpoint with VisibilityTimeout=0
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions