another technical blog...technically

Thursday, April 27, 2017

A simple Blue Prism multi-robot example

I will talk about one of the most interesting things I've seen on Blue Prism, we're talking about multi-robot and task concurrency.
As you already know, to build a process on Blue Prism, you have to use one or more queues, which are built to manage concurrency between multiple robots.
The question is: how to optimize concurrency among multiple robots?
The answer is in the process design.
Let's think about the typical producer-consumer model we deal with when we tipically work with multi-thread and let's imagine three robots up and running.
Like you see i defined a main flow which references two subprocesses: producer and consumer.
The main flow is a infinite loop that will be started from the scheduler, to stop the loop you can use a decision stage that checks a finish time, written on an environment variable.
The first subprocess is the producer and populates the work queue.
It's kinda best practice to put a environment lock before the producer starts in order to have just a robot at a time working on the producer process.
This is due to the fact we want to avoid multiple robot to do concurrently the queue population process and not so useful checks on already existing queue items.
Consumer it's a simple loop that iterates on the queue until the queue itself it's empty, no lock here, because Blue Prism deals with concurrency and locks the work item itself.
I know it's a very simple process but this is the baseline for other stuff, right now i'm working on a process which has something like 2 producers and 3 consumers, playing with environment locks on producer processes i can optimize concurrent robot performances.
I heard someone who preferred to pre-assign work item to different robot but i think this is not a good idea, this is because you cannot be sure a single work item requires the same amount of time.
For example, in one of our project we had some work item requiring up to 7 hours of robot effort.
Item name Assigned to Avg duration
1 Robot 1 7h
2 Robot 2 1h
3 Robot 3 1h
4 Robot 1 6h
5 Robot 2 2h
6 Robot 3 3h

If you work the items with pre assignation you will have this work duration
Robot 1: 13h
Robot 2:   3h
Robot 3:   4h

This means you'll have very low efficiency on Robot 2 and Robot 3. Applying the multi-robot model you'll have something like this
Robot 1: 7h (1)
Robot 2: 1h (2) + 6h (4)
Robot 3: 1h (3) + 2h (5) + 3h (6)

As you can see you will have a workforce that dinamically take in account a queue item and tries to process item as fast as possible.
If you also have more than one process (i hope for you so) on your BP server, you can also think about a main process that plays with all registered processes in order to use robot workforce in the best way.

Friday, April 14, 2017

A Blue Prism project with custom DLLs

Lately i worked a lot on Blue Prism, which is a RPA software which helps you deal with process automation.
One of the most interesting things about Blue Prism, is that you can use a lot of custom code in order to power up your solution.
For example i designed one of the solution our customers appreciated a lot simply mixing up some old school programming with brand new Blue Prism knowledge.

Let me show you context and architecture before dealing with tips and tricks.
Basically, we need to get some data from the legacy mainframe systems of the customer and we use BluePrism to deal with that using some scripting techniques.
Those data will be used to produce some documents that will be produced starting from some templates which contain some logic.
For example, in the document templates, we have some placeholder like

{FOREACH:PEOPLE}
- Name is {NAME} and surname is {SURNAME}
{/FOREACH:PEOPLE}

that will be translated in
Name is Luke and surname is Skywalker
Name is Anakin and surname is Skywalker
Name is Leila and surname is Organa

where PEOPLE is a Blue Prism collection, or other placeholders that enable a paragraph to be shown or not in some particular circumstances.
This kind of work is done using OpenXML together with Blue Prism using a basic three-tier architecture, if you're curious about, please have a look at this image below.
Why a three tier? Because we share the business logic layer between the application and the robot.
Like you can see in the image, we have an application which deals with a custom DB and is capable of getting data from Blue Prism elaboration in order to create a attended process.

What seems to be not so funny is the fact that BP 5.0.23 is that, even if you reference some DLL (and the code seems to compile) when you run the process, Blue Prism will not work correctly, so you'll need to put all the DLLs into the Blue Prism automate folder, this means you also have to put in that folder also the .config file which contains connection strings or other stuff. This package will be deployed to every robot that will work the process, or maybe could be a the robot itself to download needed DLLs using a configuration process.

What about data transfer between Blue Prism and C#/VB.Net code?
You always have to think about BP Data structure, so, if you have to read a object collection, you have to translate it into a DataTable, in order to read it from Blue Prism, so here's a bit of code to accomplish the task

Me, myself and I

My Photo
I'm just another IT guy sharing his knowledge with all of you out there.
Wanna know more?