cancel
Showing results for 
Search instead for 
Did you mean: 

sharing objects in memory

marco.pogliaghi
Level 3
Hi all,
I was trying to used objects to store information for processes to be used in other objects without passing them, but failed.
I try to better explain here:
I collect all errors I have during a process in some structures (collections and variables), I then send those errors in mail (or I write them in an excel file).
As I do this in all my processes, I would like to have objects that incorporate these functionalities.
I thought to have understood that memory space of an object is one for every object, that is I cannot have two instances of a same object running in a process, or, in other words, every object is a singleton within a process.

I thought to use this property to have:
    - an Error Collection Object
    - a Mail Object
    - a Report Generator Object

Inside the mail object I have an action "mail the errors" (same in Report generation with a "make error report"), and I tried to have those action call the "Error collection" Object, without having to pass parameters from the main process .

What I have is that If I use the "Error Collection Object" inside the process, I can see my errors just like I wanted., even in different pages, without having to share variables or so.
But the "Mail Object" called by the same process, isn't seeing the same "Error Collection Object" used by the caller process.

What have I misunderstood?

Thank you,
      marco




I would like to
1 BEST ANSWER

Helpful Answers

ewilson
Staff
Staff
@Marco Oreste Pogliaghi,

May I ask what run-mode are your objects set to - Background, Foreground, or Exclusive? And have you tried setting the Shareable flag on the Singleton Test Server object?

Cheers,
Eric​

View answer in original post

6 REPLIES 6

ewilson
Staff
Staff
@Marco Oreste Pogliaghi,

If I understand correctly, you're trying to use objects as a communication bridge across Blue Prism processes, correct? If so, that's not supported in Blue Prism to the best of my knowledge. You could certainly pass your actual Collections and variables between processes though. Otherwise, you could achieve something like this using a 3rd party tool/library/application that would basically serve as a sort of gateway or bus between the processes. Some examples would be things like Apache Kafka, RabbitMQ, ElastiCache, etc.

You could also make use of Work Queues to pass information back and forth between queues, but you'd need to give some thought to how your processes would manage maintenance/upkeep of the queues.

Cheers,
Eric​

marco.pogliaghi
Level 3
Hi Eric, it is not an inter-process communication, but just a "family" of facilities, a sort of utility framework, using within a single process.
I made a littel exampple of the type of behaviour I'm trying to have:
I have
  + a "Singleton Test Server" object that exposes three actions:
      - "set": to set an integer value,
      - "add" to add a value to the number stored,
      - "get" to get the stored number
  + a "Singleton Test Writer" object that exposes these actions:
      - "setPath" to set the path of the file being written
      - "Write the Number" that:
               * calls "add" of "Singleton Test Server" with a value of 3
               * calls the "get" action  of "Singleton Test Server" object to get the number stored
               * writes to a text file a string with the current date, the string "STW" and the number obtained in the previous step
  + the "Singleton Test Process" process: this process in its main Page:
        1. calls setPath of the "Singleton Test Writer" object to set the path where to write,
        2. call the "set" action of the "Test Signleton Server" objetc to set the value of the number store by the object (parameter: 10)
        3.  calls the "Write the Number" action of "Singleton Test Writer"
        4.  calls the "get" action  of "Singleton Test Server" object to get the number stored
        5. writes in the same file passed as path to the "Singleton Test Writer" writing the timestamp, the string "PRC" and the value of the variable obtained before
        6. makes three calls to another page "Increment and Write" that:
                6.a calls "add" of "Singleton Test Server" with a value of 10
                6.b calls the "Write the Number" action of "Singleton Test Writer"
                6.c calls the "get" action  of "Singleton Test Server" object to get the number stored
                6.d writes in the same file passed as path to the "Singleton Test Writer" writing the timestamp, the string "PRC" and the value of the variable obtained before
what I'd like to obtain is a file like this;
[2022-03-02 08:26:16] STW 13
[2022-03-02 08:26:18] PRC 13
[2022-03-02 08:26:19] STW 26
[2022-03-02 08:26:19] PRC 26
[2022-03-02 08:26:20] STW 39
[2022-03-02 08:26:20] PRC 39
[2022-03-02 08:26:21] STW 52
[2022-03-02 08:26:21] PRC 52
what I get is:
[2022-03-02 08:26:16] STW 3
[2022-03-02 08:26:18] PRC 10
[2022-03-02 08:26:19] STW 6
[2022-03-02 08:26:19] PRC 20
[2022-03-02 08:26:20] STW 9
[2022-03-02 08:26:20] PRC 30
[2022-03-02 08:26:21] STW 12
[2022-03-02 08:26:21] PRC 40

That is: it seems that the "Singleton Test Server" object in the process is not the same as the one used by "Singleton Test Writer" object (even if the two "Singleton Test Server" maintains their status across the calls, and this is good for me) .

ewilson
Staff
Staff
@Marco Oreste Pogliaghi,

May I ask what run-mode are your objects set to - Background, Foreground, or Exclusive? And have you tried setting the Shareable flag on the Singleton Test Server object?

Cheers,
Eric​

marco.pogliaghi
Level 3
Great point Eric! It was just the "Shareable " property that make the thing working as I wanted.

I've tried also with all three foreground, background,  exclusive modes, nothing changed regarding the results.

Maybe I have to study which configuration best fit my needs, but shareable is surely what I neeed for the result.

Thank you,
      marco

ewilson
Staff
Staff
@Marco Oreste Pogliaghi,

Just as an FYI for anyone who's interested in this thread. :)

I implemented your test scenario. I set the run-mode of each object to Background and I checked the Shareable flag on the Singleton Test Server VBO. After running the test, here's the output in my log file:

36376.png
Cheers,
Eric​

ewilson
Staff
Staff
This was an interesting question as I haven't come across a specific use case for myself where I needed a Singleton instance, but it's good to know how to handle it now. :) There's also a pretty good explanation of how the Shareable flags works between processes, objects, and sub-processes at the following link:

https://bpdocs.blueprism.com/bp-6-10/en-us/frmStagePropertiesObjectInfo.htm

Cheers,
Eric