actor

When to use actors instead of messaging solutions such as WebSphere MQ or Tibco Rendezvous?

岁酱吖の 提交于 2019-12-03 18:18:08
问题 I've already read the question and answers to What design decisions would favour Scala's Actors instead of JMS?. Usually, we use messaging solutions which have existed for years already: either a JMS implementation such as WebSphere MQ or Apache ActiveMQ is used for Point-To-Point communication, or Tibco Rendevous for Multicast messaging. They are very stable, proven and offer high availability and performance. Nevertheless, configuration and setup seem much more complex than in Akka. When

How to determine the number of actors to spawn in akka?

佐手、 提交于 2019-12-03 17:15:06
I have recently started looking into the Akka 2.0 framework and was able to get some code running, spawning actors that perform simple oracle database calls, performing simple calculations and whatnot, nothing in production however. What I want to know, is there a general rule of thumb or best practice to determining how many actors to spawn for certain types of tasks? Say for example, I have a connection pool of 200 jdbc connections, Do I create an actor to represent each connection? Do I create a handful of them and use a round-robin approach? Thanks. Note that numberOf(actors) != numberOf

How to hide Akka remote actors from lookup?

╄→гoц情女王★ 提交于 2019-12-03 16:32:02
I am running the Akka 2.0.2 microkernel and want to implement an authentication scheme for untrusted remote actors. The first thing that comes to mind is to set up an authentication actor which returns a reference to the work actor when authentication succeeds. However, how should I protect the work actor from simply being directly looked up remotely via actorFor(), circumventing authentication altogether? That is, I want to prevent remote actors from accessing actors in my microkernel actor system without authentication. Not giving the work actor a name in actorOf() is not enough, because it

Can I customize azure service fabric vm nodes?

大兔子大兔子 提交于 2019-12-03 15:00:22
I would like to leverage reliable actor model in the azure service fabric. Our actor model computation requires specific software installed on the vm node. Can I have custom software installed (on top of the azure service fabric software) in the vm nodes so that I can leverage this software in the actor model computation? As part of the my actor model deployment into azure service fabric, can I author this custom software installation into it? Is this how it should be done? Or are there any other ways? Or is it even possible? Raghu/.. You have multiple options: Install the software manually on

Migrating from Java concurrency to Scala concurrency

☆樱花仙子☆ 提交于 2019-12-03 14:36:31
I have a fairly standard mechanism in Java for solving the problem: Work items must be scheduled to execute at a particular time Each work item must then wait on a condition becoming true Work items should be cancellable The solution I use is as follows: Have a single-threaded scheduler to schedule my work items Have an ExecutorService (which may be multi-threaded) Each scheduled work item then submits the actual work to the ExecutorService . The returned Future is cached in a map. A completion service is used to remove the future from the cache when the work is completed Items can be

Akka Actor - wait for some time to expect a message, otherwise send a message out

非 Y 不嫁゛ 提交于 2019-12-03 12:46:49
Is it possible to make an Actor wait for X amount of seconds to receive any message, and if a message is received, process it as usual, otherwise send a message to some other Actor (pre-determined in the constructor)? Viktor Klang Yes, if you want to wait for any message, you simply set a receiveTimeout : http://doc.akka.io/docs/akka/current/scala/actors.html#receive-timeout (The docs is slightly misleading here, you can set the receiveTimeout after every message also) Tomasz Nurkiewicz It's possible, have a look at Akka Actor "ask" and "Await" with TimeoutException . But keep in mind that

stacking multiple traits in akka Actors

点点圈 提交于 2019-12-03 12:27:31
问题 I'm creating multiple traits which extend Actor. Then I want to create an actor class which uses some of these traits. However, I'm not sure how to combine the receive methods from all traits in the receive method of the Actor class. Traits: trait ServerLocatorTrait extends Actor { def receive() = { case "s" => println("I'm server ") } } trait ServiceRegistrationTrait extends Actor { def receive() = { case "r" => println("I'm registration ") } } The Actor: class FinalActor extends Actor with

Why is the actor “ask” pattern considered an anti-pattern or “code smell?”

痞子三分冷 提交于 2019-12-03 11:55:34
From what I've gathered, the "ask" pattern is considered a bad practice and should be avoided. Instead, the recommended pattern is the "actor per request" model. However, this doesn't make sense to me, as the "ask" pattern does exactly this - it creates a lightweight actor per request. So why is this then considered bad, especially when futures are far more composable and are able to more elegantly handle the collation of multiple send/receives? From Akka docs : "There are performance implications of using ask since something needs to keep track of when it times out, there needs to be

Using Futures in Akka Actors

不羁岁月 提交于 2019-12-03 11:42:32
问题 I'm just starting to learn Akka Actors in Scala. My understanding is that messages received by an Actor are queued in an Actor's mailbox, and processed one at a time. By processing messages one at a time, concurrency issues (race conditions, deadlocks) are mitigated. But what happens if the Actor creates a future to do the work associated with a message? Since the future is async, the Actor could begin processing the next several messages while the future associated with the prior message is

How do I create a TestActorRef in Scala for an Actor with constructor params?

故事扮演 提交于 2019-12-03 09:50:27
The Akka Testing docs give the following way to create a TestActorRef: import akka.testkit.TestActorRef val actorRef = TestActorRef[MyActor] How do I extend this for testing an existing actor that takes constructor arguments? When I try running this as is, substituting in my actor class, I get the following error: "error while creating actor akka.actor.ActorInitializationException:Could not instantiate Actor Make sure Actor is NOT defined inside a class/trait, if so put it outside the class/trait, f.e. in a companion object, OR try to change: 'actorOf(Props[MyActor]' to 'actorOf(Props(new