Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create reply message on request


@WavePacket wrote:

 

I'm wondering for the quoted section if we actually describing the same thing, just using different language. How I was using "async reply" was that in as a part of A receiving the message, it also sends a message to root a message that it's finished. Here, we aren't using the send and wait for response vi. ("Sync reply" was how I was trying to describe a reply message which uses send and wait for response vi.)

 

We are describing the same thing.  I offered alternatives to your word choices to make future conversations easier.

0 Kudos
Message 31 of 33
(836 Views)

@drjdpowell wrote:

@BertMcMahan wrote:

You can do some "sorta-sync" messages too. As one option, you could send actor B a regular message with payload containing a queue and an interface or abstract message. When B takes its measurement, it will send that measurement back on the specified queue. This is sort of like a synchronous message, but actor A now can do whatever it wants until actor B's message comes back. Since A is describing a message that will later be sent to itself, it can create that message with all of the "next step", "next state", etc stuff built in. The difference is that actor A doesn't simply lock up waiting on the new message. You do have to maintain state in A with this paradigm though and can't do a simple loop like you would otherwise.

 

 


What you describe is what I call an "Asynchronous Request-Reply with Continuation" (the message A provides to send to itself represents the "continuation" of the action).  

Catchy name.  🙂

 

Actually, I'm just glad the technique *has* a name.  I've used it myself, a few times.  Self-addressed messages are great for this, btw.

 

We don't cover them in the course, but you can find them on the AF palettes.  The idea is that you preload a message with data and final destination, and give that message to another actor.  That actor can send the message at any time, with no knowledge of what it is sending, or to whom.

 

I should do a video on this.  I'm looking at a slow quarter...

 


@drjdpowell wrote:

Of course, I admit you lose some functionality, like timeouts, going this route, but you avoid the synchronous message issues too.


You can do this with a timeout, BTW, and there is a subvi to do that in Messenger Library.  On timeout, one is sent a "Timed out" error message.  


I'm not fond of timeouts in these scenarios, though I freely admit that sometimes they are unavoidable.  I worry about what happens if you time out and then get the message you were originally supposed to get.  You can find yourself in a weird state if you don't manage for that possibility.  It is manageable; it's just another layer of complexity.

 

@drjdpowell In the Messenger Library, does the responding actor send the message on timeout?

0 Kudos
Message 32 of 33
(833 Views)

In Messenger Library, I use a short-lived Async subVI that either forwards the reply OR times out and sends a timeout message.  It never does both, for the reasons you describe.  

0 Kudos
Message 33 of 33
(830 Views)