Coder Social home page Coder Social logo

Comments (7)

DavidGarciaCat avatar DavidGarciaCat commented on June 25, 2024 1

Tested and working - many thanks guys!

from bccresquebundle.

danhunsaker avatar danhunsaker commented on June 25, 2024

The way Resque handles this is by creating multiple queues. Say, default, high, emergency, and low. When you start your worker(s), you can choose to dedicate workers to certain queues (such as one or two that only listen on emergency), or to list the queues in descending order of precedence (say, five workers listening to emergency,high,default,low). Resque will check each queue in order, and process the first job it finds, whatever queue it might be from. In your example scenario, your high priority job would be run by the first worker to finish any other job, and no low priority jobs would be touched until the default queue is empty.

Hopefully that makes sense.

from bccresquebundle.

DavidGarciaCat avatar DavidGarciaCat commented on June 25, 2024

Hello @danhunsaker

Yes, that makes sense, but it means I have one more question. Based on the example code that we can find in README.md file:

<?php

// get resque
$resque = $this->get('bcc_resque.resque');

// create your job
$job = new MyJob();
$job->args = array(
    'file'    => '/tmp/file',
    'content' => 'hello',
);

// enqueue your job
$resque->enqueue($job);

How can I specify the queue to use? I don't see it neither on this example nor on other examples (looking for default to find it).

Thanks for your help,

from bccresquebundle.

DavidGarciaCat avatar DavidGarciaCat commented on June 25, 2024

Is this the way?

<?php

namespace My;

use BCC\ResqueBundle\Job;

class MyJob extends Job
{
    public function __construct()
    {
        $this->queue = 'my_queue';
    }

    public function run($args)
    {
        ...
    }
}

from bccresquebundle.

nickdtodd avatar nickdtodd commented on June 25, 2024
<?php

// get resque
$resque = $this->get('bcc_resque.resque');

// create your job
$job = new MyJob();
$job->queue = 'queue_name';
...

For your first example.

from bccresquebundle.

danhunsaker avatar danhunsaker commented on June 25, 2024

If you know a job will always be placed on a certain queue, you can declare that in the class definition itself, but otherwise, the above is your best bet.

from bccresquebundle.

DavidGarciaCat avatar DavidGarciaCat commented on June 25, 2024

Hi @nickdtodd and @danhunsaker

Thanks for your replies. I will try to test this.

Enjoy the rest of your day!

from bccresquebundle.

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.