Mqtt subscriber on Actor model

57 views
Skip to first unread message

Srinivas Aditya

unread,
Jul 19, 2022, 5:03:29 AM7/19/22
to thespian.py
HI,

I'm a newbie at actor model and pretty nascent working with Thespian, please pardon me for any silly doubts and terminologies.
So I'm trying to code MQTT Subscriber into actor model using Paho library. Goal is to have concurrent actors of the subscriber so that when launched from different cmd terminals (or from any other application), multiple subscribers must be started with same functionality.
As of now when I'm launching this, single subscriber is running, but not working when relaunching in another terminal.
Not sure if I'm right direction or not, please suggest what am I doing wrong in the following code.

Please Help.Screenshot from 2022-07-19 14-30-25.png
mqtt_sub.py

Kevin Quick

unread,
Jul 19, 2022, 5:12:06 PM7/19/22
to Srinivas Aditya, thespian.py
By default the `ActorSystem(...)` call starts a system-wide "daemon".  This would allow different processes to create actors that can all communicate with each other.

Alternatively, you can use the `transientUnique` argument for `ActorSystem` to start a process-local actor system (see https://thespianpy.com/doc/using.html#hH-f71b7bfa-c57b-4716-a2c7-ad83a2ed3582).  Actors created for this type of ActorSystem will only be able to communicate with other Actors created by the same process (unless using a Convention).

Within any ActorSystem (system-wide or process-local), the use of `globalName` for Actor creation ensures only a single actor of that name is created within the ActorSystem.

In your situation, you have created a system-wide ActorSystem, and used `globalName` to ensure only a single "Subscriber" Actor is created within that system, which is why running this script in other processes does not create any additional Actors.

-Kevin



--
You received this message because you are subscribed to the Google Groups "thespian.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thespianpy+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/thespianpy/4d41f859-eeff-4ca4-8967-be79090430c0n%40googlegroups.com.


--
-KQ
Reply all
Reply to author
Forward
0 new messages