Laravel Queue Eloquent Issue

时间:2017-02-01 09:49:21

标签: php laravel eloquent queue jobs

我目前正在使用https://github.com/Parziphal/parse以能够以雄辩的方式使用Parse数据库。我面临的问题是在handle()函数中,我试图更新某个值。然而,这项工作不断重复,并没有完成。在我看来,handle()函数内对数据库的任何调用都会导致此问题。

任何想法都会受到赞赏。

class SendQueuedSMS extends Job implements SelfHandling, ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    public $receipt = null;

    public function __construct(Receipt $receipt ) {
        $this->receipt = $receipt ;
        $this->sendSlack("Constructor ");

    }

    public function handle() {
        // Send SMS
        $this->sendSlack("Status: " . $this->receipt->getObjectId());
        $this->receipt->set("smsStatus", "true");
        $this->receipt->save(); // can't get pass here
        return;
    }

    public function failed(Exception $exception) {
        $this->sendSlack($exception->getMessage());
    }

}

我清除了我的日志并再次测试,发现它输出了这个错误。

[2017-02-01 20:34:24] local.ERROR: Exception: You must call Parse::initialize() before making any requests. in /var/www/html/housetrac.com/vendor/parse/php-sdk/src/Parse/ParseClient.php:415
Stack trace:
#0 /var/www/html/housetrac.com/vendor/parse/php-sdk/src/Parse/ParseClient.php(319): Parse\ParseClient::assertParseInitialized()
#1 /var/www/html/housetrac.com/vendor/parse/php-sdk/src/Parse/ParseQuery.php(376): Parse\ParseClient::_request('GET', 'classes/Receipt...', NULL, NULL, false)
#2 /var/www/html/housetrac.com/vendor/parse/php-sdk/src/Parse/ParseQuery.php(306): Parse\ParseQuery->find(false)
#3 /var/www/html/housetrac.com/app/Http/Controllers/Traits/ParseHelper.php(215): Parse\ParseQuery->first()

似乎ParseClient没有像引导程序那样初始化。

已修复 - 已添加初始化代码

所以我包含了ParseSDK的初始化代码并且它有效。

    ParseClient::initialize('MYAPP', '', MYTOKEN');
    ParseClient::setServerURL('http://127.0.0.1:4040', 'parse');

但是,我很确定每次都要初始化ParseClient并不好。有没有人遇到过这个,有没有更好的方法来处理这个?

0 个答案:

没有答案