dqtiober37522 2017-06-11 08:04
浏览 281
已采纳

Laravel作业在队列中多次执行

Hi I have a laravel job as follows:

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 Timeline\Timeline;

class testQueue implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle(Timeline $timeline, $tag)
    {
        $tagData = $timeline->getTagFeed($tag)->getRankedItems();

        if ($tagData) {
            echo "boom";
        }    
    }
}

I'm running it via a route as follows:

Route::get('/queue', function () {
    $timeline= new Timeline();

    $timeline->login("test", "testpwd");
    Queue::later(5, new testQueue($timeline, "Testtag"));
});

Then on the commandline I ran:

php artisan queue:listen database

However, that one job is running 255 times instead of 1 times and exiting successfully.

What am I doing wrong?

  • 写回答

2条回答 默认 最新

  • doupike2351 2017-06-11 08:33
    关注

    The documentation states:

    Binary data, such as raw image contents, should be passed through the base64_encode function before being passed to a queued job. Otherwise, the job may not properly serialize to JSON when being placed on the queue.

    So you shouldn't use public function handle(Timeline $timeline, $tag) (or public function handle(Instagram $currentInstagram, $tag) in your conversation, as the Timeline or something is binary data.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块