Closed eneskaya closed 2 years ago
Hi, could you post the content of worker.php
?
Hi, could you post the content of
worker.php
?
Yes, of course. Here you go:
<?php declare(strict_types=1);
use Bref\LaravelBridge\Queue\LaravelSqsHandler;
use Illuminate\Foundation\Application;
require __DIR__ . '/vendor/autoload.php';
/** @var Application $app */
$app = require __DIR__ . '/bootstrap/app.php';
/**
* For Lumen, use:
* $app->make(Laravel\Lumen\Console\Kernel::class);
* $app->boot();
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();
Log::info('WORKER STARTED!');
return $app->makeWith(LaravelSqsHandler::class, [
'connection' => 'sqs', // this is the Laravel Queue connection
'queue' => getenv('SQS_QUEUE'),
]);
Edit: Versions I am using
OH I found it. It confused me so much π
In your CDK config you are adding the console
layer, but it doesn't make sense here. The console
layer is specifically for running CLI scripts or binaries.
Here you are using PHP code (files & classes) to handle the event, so you can remove it and give it another try.
I guess that nothing was displayed in the output because with the console layer your worker.php
file was executed "as-is", and the only thing it does is boot Laravel and return a service, and then it would exit (with the console layer).
Oh man, that was really the problem! It only cost me like 1 week of debugging π Thank you so much for your quick help!
Oh yeah I hate when that happens ^^
No problem!
First of all: very nice work π Love the possibility to go serverless with a Laravel project, and so far everything works except for jobs processing.
I setup everything with a CDK project, so I hope I am not missing something. But here is my setup:
The queue Lambda config looks like this:
The job that I trigger simply does
Debugging Setup
In the
worker.php
I placed a log which just logsLog::info('WORKER STARTED!');
. I also went ahead and put a log in theLaravelSqsHandler
within thehandleSqs
method, before theforeach
loopActual result
Now, when a message lands in the queue, it definitely get's handled, this is what I see in the logs:
Where I expected to also see
IT WORKED!
. What am I missing here? Thank you for a hint.