添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams
Trait method dispatch has not been applied, because there are collisions with other trait methods on 

I'm always getting the above error, now I want to use both Dispatchable and DispatchJobs in a job, how could I do that? Any help or guidance will be highly appreciated. Looked for few solutions on Laracasts but none worked.

Be careful when dispatching a job within another job! For example: JOB A and JOB B. When dispatching JOB B within JOB A, whenever something fails within JOB A after JOB B was dispatched, JOB B will be dispatched again when JOB A is being retried! – v1nk0 Dec 18, 2018 at 11:20

Jobs don't typically dispatch other Jobs, so start by removing the DispatchJobs trait. What you can do is listen for job events.

When a Job completes, it fires the after event. Listen for this event and then dispatch() the next Job within the listener:

* Bootstrap any application services. * @return void public function boot() Queue::after(function (JobProcessed $event) { // determine the job type from $event->job // then dispatch the next job based on your logic // check the job type if ($event->job instanceof MyJob) { // get the job payload to pass to next job $data = $event->job->payload dispatch(new NextJob($data)); // or use the static method NextJob::dispatch($data); Hi @btl, thank you for the reply, I still need your little guidance, now From JOB A, I need to pass some data which is going to be used in JOB B, how could I do that with the after event? And how would I recognise the particular job. I want to fire the event only when JOB A ends. Thank you :) – Siddharth Feb 17, 2018 at 7:20 thank you so much, but I also found a better solution :), just using global dispatch(); it doesn't make any conflicts and it works smoothly. – Siddharth Feb 17, 2018 at 7:26 @Siddharth do you have to explicitly set \dispatch() or simply dispatch() to make a global call to it? – Ulterior Oct 11, 2018 at 9:39

This worked for me

in side the BbtvAdvJob I dispatch again.

 dispatch(new BbtvAdvJob())->delay(3);

make sure that you recall php artisan queue:work when you change the code of the Job.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.