Support the ongoing development of Laravel.io →
Queues Architecture
Last updated 1 year ago.
0

To give a bit more detail, I'm building an in-house app kind of like Forge. There's a team who manage a number of contractors who aren't technically minded. The app I'm building steps them through the process of creating client websites, from start to final live deployment.

It encapsulates the creation / management of VCS repositories (http://codebasehq.com), deployments (http://deployhq.com) and AWS hosted CentOS boxes.

The specific example would be, when a "website" entity is created in this app, we need to:

  1. Create a VCS repository
  2. Clone an existing, boilerplate repository and push it to the new blank VCS repository
  3. Create a deployment configuration.

If (1) or (2) fail, obviously (3) won't work because it requires an existing VCS repository...

Last updated 1 year ago.
0

The solution I ended up going with was to make Task (1) fire an event that could be subscribed to in order to queue Task (2), which would fire an event that could be subscribed to in order to queue Task (3), etc...

Last updated 1 year ago.
0

Hello, I had similiar situation, I expose my solution, it can be useful to someone:

interface StepJob
{

    public function nextStep();

    public function notify(); //optionally
}
abstract class InstallationJob extends Job implements ShouldQueue, StepJob
{
    protected $plan = [ 
                               Job1::class => Job2::class,
                              JobN::class => JobX::class
   ]

    function nextStep()
    {
                  //dispatch next job based on $this->plan dependences or more complex dependences. call notify() when done.
    }
}

Create and Register a EventListener (JobsEventListener.php) for events (JobProcessed,JobFailed,JobProcessing):

    public function success(JobProcessed $event)
    {
        $job = $this->unserializeJob($event);

        Log::debug("Job Processed ".get_class($job));

        if ($job instanceof  StepJob)
        {
            $job->nextStep();
        }
    }

success function are listening "JobProcessed" Event.

Another considerations:

Process has a model related. nextStep() method updates model taking care with concurrency(using transaction and lockForUpdate). Model is created before start the process and pas on the job constructor.

Now, I need to define another similar process , and I'm thinking about to implement something like http://thispointer.com/task-grouping-using-composite-design-pa....

But I'm trying not to get too complicated.

Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.