Invoking Robots as and when QueueItems arrive

Our application receives user request for processing a task within a duedate.
Application invokes Orchestrator Rest APi, and adds queueitem with duedate for each user request.
This way the Orchestrator queue gets filled with randomly arriving queueitems.
We want to run 2 robots in the orchestrator,So, both robots read from one single queue and work on the same process in parallel.We expect that robots are listening to the queue continuously and
as and when an item arrives, one of the 2 robots(whichever idle) picks it(based on the duedate) for processing.

Question:what is the efficient way to ensure that the robots are listening to the queue?
1.Schedule robots to trigger every few minutes and inside the workflow do GetTransaction item , if present process it, else if it is null we exit.
But scheduling the robots this way is not a preferred option.

2.Follow the AddQueueItem call, by invoking StartJobs with both RobotIds,“Strategy”: “Specific”.We expect that only the idle Robot will do processing.If both Robots are busy, we expect the job to remain pending until availability of any one robot. Is this correct?

Please let us know your suggestions.

For continous processing you could use a robot that doesn’t end job when there’s nothing in the queue.
One implementation approach would be:

  • Use ReFramework as high level base
  • Modify transitions from GetTransaction state to have an additional self-transition with action of delay and condition of TransactionItem is Nothing Andalso not shouldStop
  • Modify transition from GetTransaction to end state to execute on shouldStop
  • Make sure you set shouldStop with ShouldStop activity before you get item from queue and do not get transaction if its true

That way you will have continous robots. Since theyre using the queue, it’s not possible for both of them to take the same item.