I have a situation where I have a job. Depending on a logic branch within the job it will either run 1 (how the job was first designed) or multiple routines.
For instance, for a single entity the job definition is:
- Read data from DB for entity
- Save to file
- Zip file
- Move zip to network share
It takes in a JSON string that looks like:
{
"UserId":"kbarrows",
"JobName":"JobExport",
"JobQueueName":"data_exports",
"JobType":4,
"JobStatus": 0,
"EntityId": 3
}
Now we want to, if the Entity ID is EMPTY (see below) get a list of entities to operate on from the DB. (could be 6 or 7 entities).
{
"UserId":"kbarrows",
"JobName":"JobExport",
"JobQueueName":"data_exports",
"JobType":4,
"JobStatus": 0,
}
For each entity, run above job. Complete the main job once all the sub-jobs are completed. Right now I am doing this with a Parallel.ForEach() method. I am thinking I might be able to Enqueue a “new” job instead for each entity. However, that means the main job will go on it’s way without knowing the outcome of each sub job.
Is there a way to do this? Should I do this?