imTigger / laravel-job-status

Add ability to track Job progress, status and result dispatched to Queue.
MIT License
407 stars 60 forks source link

How can I define the queue to use when dispatching the job? #27

Closed henderbj closed 5 years ago

henderbj commented 5 years ago

This is written in the Readme.md:

In your Job dispatcher, call $job->getJobStatusId() to get $jobStatusId:

<?php
$job = new TrackableJob([]);
$this->dispatch($job);

$jobStatusId = $job->getJobStatusId();

How can I dispatch the job to another queue instead of "default"?

I already tried: $this->dispatch($job)->onQueue("custom_queue");

The laravel log contains these messages:

[2019-02-12 23:58:42] dev.ERROR: Call to a member function onQueue() on integer {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0) : Call to a member function onQueue() on integer at /home/ansible/apps/laravel/single-project/laravel-ffmpeg-cluster/ffmpeg-cluster/app/Http/Controllers/TranscodeControll er.php:125) [stacktrace]

0 [internal function]: App\Http\Controllers\TranscodeController->encode(Object(Illuminate\Http\Request))

1 /home/ansible/apps/laravel/single-project/laravel-ffmpeg-cluster/ffmpeg-cluster/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_arra

y(Array, Array)

Thanks in advance.

henderbj commented 5 years ago

I figured it out: `

$job = new TrackableJob([]); $job->onQueue($my_local_queue); $this->dispatch($job);

$jobStatusId = $job->getJobStatusId(); `

We can close this issue.