You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am wondering if it is possible to instantiate inside an object in Scala (called for example FirstObject) a zio actor, and then be able to pass the reference of this actor into another Scala object (called for example SecondObject), and to call in SecondObject the ask method (?) on the actor reference , so as to send messages to the actor.
I have this doubt because I have done some trials, but only if I send messages to the actor via the ask method in the object in which the actor is created (FirstObject), do I get a response from the actor, otherwise if I call the ask method in SecondObject, the application remains blocked waiting for the response of the actor (without ever receiving it).
I tried in FirstObject to save the actor reference in the variable reference
val myAppLogic = for {
system <- ActorSystem("mySystem")
MyActorReference <- system.make("MyActor ", Supervisor.none, (), stateful)
} yield (reference = MyActorReference )
and then pass this variable inside SecondObject, so as to insert it in the zio effect:
val myAppLogic = for {
response<- reference ? MyCommand(SomeCommand)
_ <- printLine("The response is: ",response)
} yield ()
Could someone help me figure out what is wrong with my code, or in general if it is possible to implement this behavior?
The text was updated successfully, but these errors were encountered:
Hi,
I am wondering if it is possible to instantiate inside an object in Scala (called for example FirstObject) a zio actor, and then be able to pass the reference of this actor into another Scala object (called for example SecondObject), and to call in SecondObject the ask method (?) on the actor reference , so as to send messages to the actor.
I have this doubt because I have done some trials, but only if I send messages to the actor via the ask method in the object in which the actor is created (FirstObject), do I get a response from the actor, otherwise if I call the ask method in SecondObject, the application remains blocked waiting for the response of the actor (without ever receiving it).
I tried in FirstObject to save the actor reference in the variable reference
and then pass this variable inside SecondObject, so as to insert it in the zio effect:
Could someone help me figure out what is wrong with my code, or in general if it is possible to implement this behavior?
The text was updated successfully, but these errors were encountered: