Skip to main content
Kofax

Code sample for queuing robots called through API

3029733

Question / Problem: 

At this time, robots called from API are not queued when there are no available slots to run them.

But the API code that calls the robot can be edited to include a retry functionality.

Answer / Solution: 

The attached file (QueueRobot.java) contains an example on how to create a retry functionality using the Java API.

The method to call the robot itself is copied from the Management Console > Repository (by clicking the API button corresponding to the robot). The code then only adds a loop to retry the robot execution in case the previous execution has returned a "no available slots" message.

In summary, the code follows these steps

  • configure the repository
  • register cluster
  • try to run the robot and catch the message it receives
  • if the robot run succeeds then end here
  • if the robot doesn't run and gets "no available slots" then wait 61 seconds and try again.
  • if the robot gets a different error then log it and end
  • the loop is retried for maximum 5 times (this is configurable in the while-do)

Note: the wait between retries has to be 60 seconds or higher. This is because when the cluster is registered ( Request.registerCluster(client, clusterName )) the API is configured to synchronize with the Management Console automatically. This is done using a background thread that refreshes the state of the RoboServers every minute.

 

Applies to:  

Product Version
RPA 11.1 and Earlier

 

 

  • Was this article helpful?