marek.knappe's avatar

Lumen queue listener with SQS queue

Hey,

I tried many different ways of doing that, and trying to get everything from documentation but maybe I'm too stupid for that :) what i did is: config/queue.php

    'sqs' => [
            'driver' => 'sqs',
            'key'    => env('AWS_KEY', 'no-key'),
            'secret' => env('AWS_SECRET', 'no-secret'),
            'queue'  => env('AWS_QUEUE','no-default-queue-url'),
            'region' => env('AWS_REGION','no-region')
        ],

and all of these are correctly in my .env file

i did new file: app/Jobs/SlackInJob.php

<?php

namespace App\Jobs;



class SlackInJob extends Job
{




    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle($test,$test2)
    {
      return true;
    }
}

and send message to queue:

{"job":"App\\Jobs\\SlackInJob","data":{"id":1,"sth":"sth"}}

but getting error:

marek@Mareks-MacBook-Pro ~/P/opsbot-messagesend> php artisan queue:listen

Fatal error: Call to undefined method App\Jobs\SlackInJob::fire() in /Users/marek/Projects/opsbot-messagesend/vendor/illuminate/queue/Jobs/Job.php on line 129



  [Symfony\Component\Debug\Exception\FatalErrorException]
  Call to undefined method App\Jobs\SlackInJob::fire()




Fatal error: Call to undefined method App\Jobs\SlackInJob::fire() in /Users/marek/Projects/opsbot-messagesend/vendor/illuminate/queue/Jobs/Job.php on line 129



  [Symfony\Component\Debug\Exception\FatalErrorException]
  Call to undefined method App\Jobs\SlackInJob::fire()




Fatal error: Call to undefined method App\Jobs\SlackInJob::fire() in /Users/marek/Projects/opsbot-messagesend/vendor/illuminate/queue/Jobs/Job.php on line 129



  [Symfony\Component\Debug\Exception\FatalErrorException]
  Call to undefined method App\Jobs\SlackInJob::fire()

So I see that lumen is connecting with no issue to queue and getting message, the problem is that fire is abstract class in Job, so there is some reason why lumen is not loading automatically SqsJob class instead of just simple Job

I also tried to do class SlackInMessage extend SqsJob - but they were getting:

  [Illuminate\Contracts\Container\BindingResolutionException]
  Unresolvable dependency resolving [Parameter #0 [ <required> array $config ]] in class Aws\Sqs\SqsClient
0 likes
1 reply
marek.knappe's avatar
marek.knappe
OP
Best Answer
Level 1

Ok i fixed the problem, the problem was that i was putting message to queue myself which looks like:

{"job":"App\\Jobs\\SlackInJob","data":{"id":1,"sth":"sth"}}

but the real message generated from framework (Job class) is:

"job":"Illuminate\\Queue\\CallQueuedHandler@call","data":{"command":"O:27:\"App\\Jobs\\SlackInvitationJob\":3:{s:8:\"\u0000*\u0000email\";s:12:\"test@test.pl\";s:11:\"\u0000*\u0000username\";s:5:\"marek\";s:6:\"\u0000*\u0000job\";N;}"}}

Please or to participate in this conversation.