actor

Akka 2.1 minimal remote actor example

孤街浪徒 提交于 2019-12-17 22:37:25
问题 EDIT Notice, I needed to make the reverse changes of this https://github.com/akka/akka/commit/ce014ece3568938b2036c4ccfd21b92faba69607#L13L6 to make the accepted answer work with AKKA 2.1 which is the stable distribution found on akkas homepage! I have read all the tutorials I could find on AKKA, but nothing I found works "out of box". Using eclipse, I want to create 2 programs. Program1: starts actor "joe" and somehow makes it available on 127.0.0.1:some_port Program2: gets a reference to

Actions of Actors in libgdx

≯℡__Kan透↙ 提交于 2019-12-17 22:32:26
问题 I have made my Actor, but I am unclear on how to take advantage of the action and act methods. Outside of the basic Javadoc, I have not found a good tutorials on these methods. Can anyone provide an example with comments for actions on actors? 回答1: This answer is being rendered obsolete because of changes in LibGDX. For up to date documentation see scene2d wiki page. There are various available actions in LibGDX ready for you. They are in com.badlogic.gdx.scenes.scene2d.actions package. I

Scala actors: receive vs react

妖精的绣舞 提交于 2019-12-17 21:26:53
问题 Let me first say that I have quite a lot of Java experience, but have only recently become interested in functional languages. Recently I've started looking at Scala, which seems like a very nice language. However, I've been reading about Scala's Actor framework in Programming in Scala, and there's one thing I don't understand. In chapter 30.4 it says that using react instead of receive makes it possible to re-use threads, which is good for performance, since threads are expensive in the JVM.

How to log all incoming messages from Akka (Java)

走远了吗. 提交于 2019-12-13 13:26:07
问题 In Scala you can wrap the receive function with a LoggingReceive. How do you achieve the same from the Java API? def receive = { LoggingReceive { case x ⇒ // do something } } 回答1: The Scala API has the LoggingReceive decorator because a partial function literal makes it awkward to express something to be done in all cases (like this logging). In Java you don’t have this problem because your onReceive method is always called, and you can put a logging statement at the top to see all messages

Scala, check if Actor has exited

寵の児 提交于 2019-12-13 13:14:22
问题 in Scala 2.8 when I start actors, I can communicate via message passing. This in turn means that I can send the ultimate Exit() message or whatever I decide fits my protocol. But how will I check if an actor has exited? I can easily imagine myself having a task where a master actor starts some worker actors and then simply waits for the answers, each time checking if this was the final answer (i.e. are any Actors still working or did they all exit?). Of course I can let them all send back an

Pros and cons in using multiple actor types in same Service Fabric service

南楼画角 提交于 2019-12-12 22:14:01
问题 When using the Azure Service Fabric Reliable Actor programming model, what are the pros and cons of using several actor types in the same service? Is it only a matter of deployment, or are there runtime considerations as well? 回答1: Pros: Increases density. Fewer projects to manage which is always helpful. Cons: The actor types within the same package will have to be deployed/upgraded at the same time and are no longer independent. My advice would be to use the same code packages if the

In Akka Java actor model, can a router create actors with non-default constructor?

不羁岁月 提交于 2019-12-12 18:16:10
问题 In Akka Java actor model, if I have a RoundRobinRouter, when its tell() method is called, I want the router (as the master) to create children actors with non-default constructor because I need to pass in some parameters. How can I do this? I understand that I can an actor with non-default constructor using Props , but how is it used when the master actor is a router? Thanks! 回答1: The props in the construction of a Router is the props for the routees of that router, not the router itself. You

How to test a public method in an akka actor?

核能气质少年 提交于 2019-12-12 15:38:20
问题 I have an akka actor: class MyActor extends Actor { def recieve { ... } def getCount(id: String): Int = { //do a lot of stuff proccess(id) //do more stuff and return } } I am trying to create a unit test for the getCount method: it should "count" in { val system = ActorSystem("Test") val myActor = system.actorOf(Props(classOf[MyActor]), "MyActor") myActor.asInstanceOf[MyActor].getCount("1522021") should be >= (28000) } But it is not working: java.lang.ClassCastException: akka.actor

Can actors read messages under a certain condition?

大兔子大兔子 提交于 2019-12-12 14:09:45
问题 I have this situation: ActorA sends ActorB start/stop messages every 30-40 seconds ActorA sends ActorB strings to print (always) ActorB must print the strings he receive, but only if ActorA sent just a start message Now i wonder if i can do the following things: Can ActorB read messages only under a certain condition (if a boolean is set as true) without losing the messages he receives while that boolean is set as false? Can ActorB read a start/stop message from ActorA before the other string

Persistent Akka Mailboxes and Losslessness

主宰稳场 提交于 2019-12-12 12:24:18
问题 In Akka, when an actor dies while processing a message (inside onReceive(...) { ... } , that message is lost. Is there a way to guarantee losslessness? Is there a way to configure Akka to always persist messages before sending them to onReceive , so that they can be recovered and replayed when the actor does die? Perhaps something like a persistent mailbox? 回答1: Yes, take a look at Akka Persistence, in particular AtLeastOnceDelivery. This stores messages on the sender side in order to also