Delay In Triggering Jobs Using Queue Trigger

How to handle the delay in triggering jobs using queue trigger?

How UiPath Queue triggers work?

For the below Queue Trigger settings, this is how the Jobs will be triggered:

Minimum number of items to trigger the first job = 1

Maximum number of pending and running jobs allowed simultaneously = 10

Another job is triggered for each = 1

How the jobs are created for queue items added to the Queue?

Job x triggered when there are ('Minimum number of items to trigger the first job' + running_jobs * 'Another job is triggered for each') new queue items in the queue.

The suggested algorithm evaluates the existing number of queue items in NEW state every time a queue item is added to the queue and decides, using the above formula, if there is a need for a new Job or not. For this case, jobs will be triggered as follows:

Job 1 triggered when there are 1 new queue items in the queue.

Job 2 triggered when there are 2 (1+1*1) new queue items in the queue.

Job 3 triggered when there are 3 (1+2*1) new queue items in the queue.

Job 4 triggered when there are 4 (1+3*1) new queue items in the queue.

Job 5 triggered when there are 5 (1+4*1) new queue items in the queue.

Job 6 triggered when there are 6 (1+5*1) new queue items in the queue.

Job 7 triggered when there are 7 (1+6*1) new queue items in the queue.

Job 8 triggered when there are 8 (1+7*1) new queue items in the queue.

Job 9 triggered when there are 9 (1+8*1) new queue items in the queue.

Job 10 triggered when there are 10 (1+9*1) new queue items in the queue.

No more Jobs are triggered when MaxJobsForActivation is reached.

What the algorithm sees for this case is:

  • When the second queue item is added, there are 0 queue items in new state in the queue at that time and there is already 1 job running
  • The condition to start the second job is not met.

The current algorithm is designed for long running jobs that process multiple queue items in a loop.

There is a cron job that runs every 30min and checks the queue. So that any NEW queue item will not stay unprocessed for more than 30min. There is no option present currently to lower this time limit as of now.

Resolution:

  • Create a job directly and pass the input arguments: Instead of using queues, make an API request to create a Job and pass the necessary input arguments
or
  • Create dummy queue items:
  1. Make an API request to get the number of running jobs and calculate the number of NEW queue items that are required in the queue for jobs to get created as per the algorithm. Assume this number is equal to "x".
  2. After the actual queue item gets created, create "x-1" additional queue items and check if jobs are created for all the queue items.
  3. Handle the dummy queue items in the workflow. Job x triggers when there are ('Minimum number of items to trigger the first job' + running_jobs * 'Another job is triggered for each') new queue items in the queue.

If SLAs are required to be implemented in the design, create a polling automation that checks the Queue every X seconds/minutes for new work. Or instead of using queues, directly make an API call to create a new job for each new mail.

To resolve the issue, either of the above options needs to be implemented.