Python based template for producer-consumer model robots using work items
This template leverages the new python open-source structure robo, the libraries from to same project as well.
The template provides you with the basic structure of a Python project: logging out of the box and controlling your tasks without fiddling with the base Python stuff, and a lot more.
log.html
under the output
-folder.
This template contains a working robot implementation that has the basic structure where one part produces work items from input and another part that consumes those work items.
The producer-consumer model is not limited to two steps, it can continue so that the consumer generates further work items for the next step and so on.
The template tries to keep the amount of functional code at a minimum so you have less to clear out and replace with your own implementation, but some functional logic is needed to have the template working and guiding the key parts.
We recommended checking out the article "Using work items" before diving in.
Tasks
The robot is split into two tasks, meant to run as separate steps in Control Room. The first task generates (produces) data, and the second one reads (consumes) and processes that data.
The first task (the producer)
- Load the example Excel file from work item
- Splits the Excel file into work items for the consumer
The second task (the consumer)
We recommended checking out the article "Work item exception handling" before diving in.
- A simulated "Login" step.
- This simulates random failures to highlight the use of
APPLICATION
-exception type.
- This simulates random failures to highlight the use of
- Loop that handles the work items and just creates a logs row for each
- This simulates random failures to highlight the use of
BUSINESS
-exception type.
- This simulates random failures to highlight the use of
Local testing
For best experience to test the work items in this example we recommend using our VS Code extensions. With the Robocorp Code extension you can simply run and select the input work items to use, create inputs to simulate error cases and so on.
For more information, do not forget to checkout the following:
- Robocorp Documentation -site
- Portal for more examples
- robo -repo as this will developed a lot...