Giter Site home page Giter Site logo

Comments (10)

gabrielalack avatar gabrielalack commented on May 22, 2024 16

I feel like there should be a warning about this on the doc page for queues. Would have saved me some time before having to come looking for this!

from tinker.

taylorotwell avatar taylorotwell commented on May 22, 2024 6

Yeah dispatch the job using Bus::dispatch or Queue::push

from tinker.

simik-ru avatar simik-ru commented on May 22, 2024 4

@mattbucci

@robclancy I find the approach
App\Jobs\SendTasksDigest::dispatch(App\User::find(5))->__destruct();
causes the job to be dispatched twice

Try the following instread:

app(\Illuminate\Contracts\Bus\Dispatcher::class)->dispatch(new \App\Jobs\MyJob());

from tinker.

robclancy avatar robclancy commented on May 22, 2024 3

For people coming here you can just destruct the object you get.

App\Jobs\SendTasksDigest::dispatch(App\User::find(5))->__destruct();

from tinker.

GrahamCampbell avatar GrahamCampbell commented on May 22, 2024 1

This is because of the dispatch helper using garbage collection to dispatch. Call Bus::dispatch() instead to avoid this.

from tinker.

mattbucci avatar mattbucci commented on May 22, 2024 1

@robclancy I find the approach
App\Jobs\SendTasksDigest::dispatch(App\User::find(5))->__destruct();
causes the job to be dispatched twice

from tinker.

GrahamCampbell avatar GrahamCampbell commented on May 22, 2024

(or whatever the name of the facade is, if one exists, you know what I mean)

from tinker.

matthewhaworth avatar matthewhaworth commented on May 22, 2024

I've just come across this, wasted many hours getting quite confused!

from tinker.

 avatar commented on May 22, 2024

Is there any more info on why this is happening? We encountered it was well and were wondering about how the dispatcher is interacting with garbage collection. Just curious mainly.

from tinker.

louisitvn avatar louisitvn commented on May 22, 2024

This is because of the dispatch helper using garbage collection to dispatch. Call Bus::dispatch() instead to avoid this.

Can anyone explain why it was intended like that? It is really annoying.

from tinker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.