[Laravel 8] Using Bus::chain() inside Bus::batch() #34332
Unanswered
ksassnowski
asked this question in
General
Replies: 2 comments
-
I don't think this can or should be handled at the framework level. Chains can have batches that have chains that have batches etc... You need to keep track of the process somewhere, like in a database. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I have a similar use case. Is it not possible to interact with the job itself, as far as I'm aware the chained jobs just attach themselves to each other in a chain (i.e |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to combine
Bus::chain()
with the newly introducedBus::batch()
in Laravel 8? Here's an example of what I want to achieve:Suppose that after a new employee gets entered into the system an onboarding process gets kicked off. Some of these steps don't have anything to do with each other, but they all need to happen for the "onboarding" to be considered completed. Some of these steps can consist of multiple sub-steps or have dependencies on each other (i.e. can't run before other jobs have been finished). I would like to model it something like this:
I know that there are a bunch of ways to deal with this without having to use a batch, e.g. using events and dispatching the next job in the process or by wrapping the chain in yet another job. But something like this would give me the ability to treat the entire batch as the overall process.
Another issue I see is that the jobs inside the chain aren't aware of the batch they're being run in. I'm also not entirely sure how the
then
andcatch
calls of the batch and chain would interact once you start nesting them.This might also be a horrible idea but I'm happy to discuss it 😅
Beta Was this translation helpful? Give feedback.
All reactions