Amazon SQS driver
babelqueue-sqs is a drop-in queue connection that makes an Amazon SQS queue
polyglot. It extends Laravel’s native sqs driver: jobs that opt into BabelQueue are
sent as the canonical envelope with the
§3 SQS MessageAttributes, so a Go, Python,
Node, Java or .NET worker can route and trace them — while standard Laravel jobs on the
same connection pass straight through unchanged.
Requirements
The AWS SDK for PHP is required (Laravel lists it as a suggestion):
composer require aws/aws-sdk-php
Configuration
Add a connection in config/queue.php with driver set to babelqueue-sqs. The
config keys are exactly Laravel’s stock sqs keys:
'connections' => [
'babelqueue-sqs' => [
'driver' => 'babelqueue-sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.eu-central-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'orders'),
'suffix' => env('SQS_SUFFIX', ''),
'region' => env('AWS_DEFAULT_REGION', 'eu-central-1'),
],
],
The connector mirrors the stock SqsConnector (credentials, prefix/suffix), so anything
that works for sqs works here. For LocalStack/ElasticMQ, set an endpoint key as you
would for the native driver.
Produce
Producing is identical to the other BabelQueue drivers — see
Producing messages. Dispatch a typed
ShouldQueuePolyglot job (or use the BabelQueue facade) onto the connection:
use BabelQueue\Facades\BabelQueue;
BabelQueue::connection('babelqueue-sqs')
->publish('urn:babel:orders:created', ['order_id' => 1042]);
The job is sent as the canonical envelope (MessageBody) with the projected
MessageAttributes (bq-job/bq-trace-id/bq-message-id/bq-schema-version/
bq-source-lang/bq-created-at). A plain Laravel job dispatched to the same connection
is encoded the normal Laravel way — no envelope, no attributes — so existing workers keep
working.
Consume
Run a worker against the connection as usual:
php artisan queue:work babelqueue-sqs
Polyglot messages — including those produced by another language’s SDK — are decoded, routed by URN through the dispatcher and handled; standard jobs run as normal. See Consuming messages for handler registration.
attemptsnote. As a Laravel driver, the reserved job surfaces the broker’s native receive count viaSqsJob::attempts()(i.e.ApproximateReceiveCount). This is the documented, exempt divergence from the framework-less SDKs, which reconcileattemptstoApproximateReceiveCount − 1— see the SQS binding.
Because the wire format is the canonical envelope, a message your Laravel app consumes may have been produced by any BabelQueue SDK, and vice-versa.