0
0
Laravelframework~10 mins

Job chaining and batching in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to chain two jobs in Laravel.

Laravel
$job1->[1]([$job2]);
Drag options to blanks, or click blank then click option'
Achain
Bdispatch
Cqueue
Dbatch
Attempts:
3 left
💡 Hint
Common Mistakes
Using dispatch instead of chain will run jobs independently.
Using batch is for grouping jobs, not chaining.
2fill in blank
medium

Complete the code to create a batch of jobs in Laravel.

Laravel
Bus::[1]([$job1, $job2])->dispatch();
Drag options to blanks, or click blank then click option'
Achain
Bdispatch
Cbatch
Dqueue
Attempts:
3 left
💡 Hint
Common Mistakes
Using chain instead of batch will run jobs sequentially, not in parallel.
Using dispatch alone does not create a batch.
3fill in blank
hard

Fix the error in the job chaining code by completing the blank.

Laravel
dispatch(new JobOne())->[1]([new JobTwo()]);
Drag options to blanks, or click blank then click option'
Abatch
Bchain
Cqueue
Ddispatch
Attempts:
3 left
💡 Hint
Common Mistakes
Using batch instead of chain causes jobs to run in parallel, not sequentially.
Calling dispatch again after dispatch causes errors.
4fill in blank
hard

Fill both blanks to create a batch with a then callback.

Laravel
Bus::[1]([$job1, $job2])->[2](function () {
    // All jobs completed
})->dispatch();
Drag options to blanks, or click blank then click option'
Abatch
Bchain
Cthen
Dqueue
Attempts:
3 left
💡 Hint
Common Mistakes
Using chain instead of batch for grouping jobs.
Using queue instead of then for the callback.
5fill in blank
hard

Fill all three blanks to create a batch with a catch callback and a name.

Laravel
Bus::[1]([$job1, $job2])
    ->[2](function (Batch $batch, Throwable $e) {
        // Handle failure
    })
    ->name('[3]')
    ->dispatch();
Drag options to blanks, or click blank then click option'
Achain
Bcatch
Cmy-batch
Dbatch
Attempts:
3 left
💡 Hint
Common Mistakes
Using chain instead of batch for grouping jobs.
Using then instead of catch for error handling.
Not providing a batch name string.