2

I am using the AWS SDK for PHP to push a message into an AWS SQS queue.

I'd like to be able to set the visibility timeout for specific messages to be different than the default. It would make sense to be able to do that, but I can't find a way to do that based on the documentation.

$message = $sqsClient->sendMessage([
   'QueueUrl' => $queueUrl,
   'MessageBody' => json_encode($request),
]);

I can see the ChangeVisibilityTimeout API call, but this requires me to either poll or consume that message then change it which seems counter-intuitive.

Ideally, i'd like to send through the visibility timeout at the same time. Is this possible in some way?

crmpicco
  • 16,605
  • 26
  • 134
  • 210

2 Answers2

2

Is this possible in some way?

Sadly, its not possible.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • Thanks for the quick reply. That was my fear. I must admit, it's quite strange that it's not possible and you are forced to make another API call. – crmpicco Dec 20 '22 at 08:59
  • @crmpicco I don't know why AWS chose to design SQS the way they did. You can always look at other queuing solutions. – Marcin Dec 20 '22 at 09:00
0

If your need to delay the message is less than 15 minutes you can use

DelaySeconds Type: int The length of time, in seconds, for which to delay a specific message. Valid values: 0 to 900. Maximum: 15 minutes. Messages with a positive DelaySeconds value become available for processing after the delay period is finished. If you don't specify a value, the default value for the queue applies.

Send message. check parameter details.

Ayush Singhal
  • 21
  • 1
  • 6