Laravel SQS队列 - >延迟工作失败

I am trying to delay a job in Laravel that is dispatched to a AWS SQS queue. Standard jobs that are not delayed run fine on that queue but as soon as I delay something, it crashes. I first tried:

$awsgatewayjob = new \App\Jobs\DispatchAwsGatewayJob();
$this->dispatch($awsgatewayjob)->delay(now()->addMinutes(1));

This gives error: Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Call to a member function delay() on string

Next, I tried to do it using the style Laravel explains in the manual:

DispatchAwsGatewayJob::dispatch()->delay(now()->addMinutes(1));

And this gives error:

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Call to undefined method Maqe\LaravelSqsFifo\SqsFifoQueue::getSeconds()

I googled the last error and I am happy to report I am not the only one that experienced that error: https://github.com/maqe/laravel-sqs-fifo/issues/7

Anyway, I don't get it. I am running on Laravel 5.5 and I updated all my packages with composer update to make sure I wasn't using an outdated package.

Any ideas?

Here is the (redacted) code for the job:

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

use Auth;
use Session;

use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Alert;


class DispatchAwsGatewayJob implements ShouldQueue
{

  private $method;
  private $rest_method;
  private $data;

  use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

  /**
  * Create a new job instance.
  *
  * @return void
  */
  public function __construct($method, $rest_method, $data)
  {
    $this->method = $method;
    $this->rest_method = $rest_method;
    $this->data = $data;

  }

  /**
  * Execute the job.
  *
  * @return void
  */
  public function handle()
  {
    $curl = curl_init();

    // some more stuff here to config $curl

    $result = curl_exec($curl);
    curl_close($curl);
  }
}

Here is the full error log:

Symfony\Component\Debug\Exception\FatalThrowableError thrown with message "Call to undefined method Maqe\LaravelSqsFifo\SqsFifoQueue::getSeconds()"

Stacktrace:

0 Symfony\Component\Debug\Exception\FatalThrowableError in /var/www/sparkwebsite/vendor/maqe/laravel-sqs-fifo/src/SqsFifoQueue.php:42

This is the complete stacktrace. I am now using a standard queue and everything runs fine!

查看全部
dongzen2675
dongzen2675
2018/03/07 22:23
  • laravel
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复