Is there a way to use Laravel's queue worker to process custom messages from an AWS SQS queue?
I have a custom queue within Amazon SQS I want to process messages from. I see Laravel has a queue listener that really does all this for you, BUT I can't find any documentation on how to build custom listeners/deserializer.
When using queue:work on the queue, Laravel is throwing an exception:
[2020-05-13 22:02:00] local.ERROR: Undefined index: job {"exception":"[object] (ErrorException(code: 0): Undefined index: job at /Users/pz/Documents/Envision/source/services/case-search/src/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:288, ErrorException(code: 0): Undefined index: job at /Users/pz/Documents/Envision/source/services/case-search/src/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:200)
The reason is because it's looking for a job index at the root of the payload. The messages does not have any such index. I need some way to catch this to run my own handler.
Example data:
(
'Type' => 'Notification',
'MessageId' => '47cffb48-3811-5c7e-af60-5d6e51ac7e48',
'TopicArn' => 'arn:aws:sns:us-east-1:xxxxxxxx:topic',
'Subject' => 'cud-event.table',
'Message' => '{
"table": "myTable",
"action": "insert",
"ts": 1589407243.8653,
"data_new": {
/// [...message data...]
}
}',
'Timestamp' => '2020-05-13T22:00:44.083Z',
'SignatureVersion' => '1',
// [... AWS sigs ...]
)
Ideally, it would be perfect if we can tell Laravel to look for "Message.table" object, e.g. myTable, or simply a noramlized "Subject" object.