Receive Message is called every time a message is received by an Actor.
When you call the parent method, the message is handled normally.
You can use an override to filter or adjust messages, for example like this:
Here I override Receive Message to check if the message is one of 4 different types: Last Ack, Stop, Report Error or "Stop Relauncher Msg". The first 3 are built-in to Actor Framework, and the last is a specific message for this class.
Here the Actor behaves somewhat similarly to the Linked Endpoint Actors. This actor generally forwards messages to a nested actor, but some messages (the 4 mentioned) need to be handled normally by this Actor.
If the message is a different one, then it is forwarded in the error case (taking care not to connect the error wire!)
Here is an example project. Root Actor Recieve Msg.vi is overridden in order to exchange messages between parallel nested actors without need to define forwarding messages in Root Actor.
The primary use case for Receive Msg is to create network proxies for distributed actor systems. Most actors receive a message and then act on it. But network proxies say, “Actually, this actor isn’t really here, it’s across the network.”
I have tried to redirect a message to a Grandchild actor which was sent from Parent actor to Child Actor. For which, I have overrided Receive Msg.vi in the Child actor. But Once i have overrided it, no msgs are getting communicated from Parent to Child, but when I checked after removing the override, the messages are getting communicated. I have attached the Project zip file. Can someone guide me with the issue....
I didn't exhaustively check your project, it's not immediately clear that you have the correct set of messages to forward vs handle (in Child1, right?) but the problem is here:
You can't use Equals to compare these effectively, instead you want to know if they're the same class. To do that, use the To More Specific node and check for an error.
Note that this won't work still, because some messages are almost certainly meant to be handled by the receiving actor here, rather than being forwarded - for example Stop Msg.
However, this structure should now work in terms of filtering - you just need to check what you're filtering and what you're receiving (note you could do both, if you wanted...)
Hi cbutcher, Thanks a lot for your prompt reply. I did changes as you suggested, now Stop msg is communicated and actor specific msg is also received but the msg i need to divert is not working properly. When I send that msg, the concerned actors get abruptly stopped. I have attached the screenshot for your ref. Thanks in advance.
Error code- 1
Generate User Event in Child 1.lvlib:Child 1.lvclass:Message Child.vi->Child 1.lvlib:Message Child Msg.lvclass:Do.vi:3750001->Actor Framework.lvlib:Actor.lvclass:Receive Message.vi:1040001->Child 1.lvlib:Child 1.lvclass:Receive Message.vi:1040001->Actor Framework.lvlib:Actor.lvclass:Actor Core.vi:5880002->Child 1.lvlib:Child 1.lvclass:Actor Core.vi:5880001->Actor Framework.lvlib:Actor.lvclass:Actor.vi:6640006->Actor Framework.lvlib:Actor.lvclass:Actor.vi.ACBRProxyCaller.BF800039
Getting this error in the error out of Receive msg.vi