Frederick Zhang Frederick Zhang - 11 days ago 8
PHP Question

How to accommodate Amazon FIFO SQS in Laravel queue?

Amazon has announced their new FIFO SQS service and I'd like to use it in Laravel Queue to solve some concurrency issues.

I've created several new queues and changed the configurations. However, I got a

MissingParameter
error which says

The request must contain the parameter MessageGroupId.


So I modified the file
vendor/laravel/framework/src/Illuminate/Queue/SqsQueue.php


public function pushRaw($payload, $queue = null, array $options = [])
{
$response = $this->sqs->sendMessage(['QueueUrl' => $this->getQueue($queue), 'MessageBody' => $payload,
'MessageGroupId' => env('APP_ENV', getenv('APP_ENV'))]);

return $response->get('MessageId');
}

public function later($delay, $job, $data = '', $queue = null)
{
$payload = $this->createPayload($job, $data);

$delay = $this->getSeconds($delay);

return $this->sqs->sendMessage([
'QueueUrl' => $this->getQueue($queue), 'MessageBody' => $payload, 'DelaySeconds' => $delay,
'MessageGroupId' => env('APP_ENV', getenv('APP_ENV'))
])->get('MessageId');
}


I'm using
APP_ENV
as the group ID (it's a single message queue so actually it doesn't matter a lot. I just want everything to be FIFO).

But I'm still getting the same error message. How could I fix it? Any help would be appreciated.

(btw, where has the SDK defined
sendMessage
? I can find a stub for it but I didn't find the detailed implementation)

Answer

Apart from the MessageGroupId, it needs a MessageDeduplicationId or enabling content-based deduplication.