actor

How can i check if an Akka actor exists (akka 2.2)?

最后都变了- 提交于 2019-11-30 11:26:39
问题 I have a java object which is not an actor which selects actors from an actor system with actorSelection(Path)). It is possible, that the selected actor does not exist in the system. In the Java Api ask() does not exist for ActorSelection, so I can not send and Identify message to the actor selection and use the sender of the response. I tried to solve the problem by sending the message to the actor anyway via the actor selection and then reacting to the deadletter. But I don't get any

Azure service fabric actor dependency injection

懵懂的女人 提交于 2019-11-30 11:05:40
Is there any way to inject dependencies in to the Azure Service Fabric Actor's constructor? Having had a bit of a dig-around in this area with dotPeek a while back (trying to resolve actors from an Autofac lifetime scope per-invocation), I think the trick is to create your own implementation of StatelessActorServiceFactory, and your own extension method to register the actor with it. Although the factory class is marked as internal, its interface (IStatelessServiceFactory) and the service type it creates (StatelessActorServiceInstance) are both public. Unfortunately, it doesn't look like

Get existing or create new akka actor

删除回忆录丶 提交于 2019-11-30 09:38:02
I'm trying to get an existing ActorRef with ActorFor or create a new one if it does not exists. I have the following code but it doesn't seem to work as expected. .isTerminated() is always true. ActorSystem system = ActorSystem.create("System"); ActorRef subscriberCandidate = system.actorFor("akka://System/user/"+name); if (subscriberCandidate.isTerminated()) { ActorRef subscriber = system.actorOf(new Props(new UntypedActorFactory() { public UntypedActor create() { return new Sub(name,link); } }), name); System.out.println(subscriber.path().toString() + " created"); } else System.out.println(

Thread.sleep inside Scala actors

扶醉桌前 提交于 2019-11-30 08:26:30
问题 Is it correct to use Thread.sleep(5000); inside an actor? Does it actualy make an actor sleep for 5 seconds? Is there a simple alternative to make an actor sleep for some seconds? 回答1: Anything that blocks a thread is not advised within Akka. If the Actor is configured with a a shared thread pool (default behavior) then using Thread.sleep will withhold a thread from that pool that could be doing work for other Actors. If one really must block, then an actor may be configured to have its own

Akka简介与Actor模型(一)

て烟熏妆下的殇ゞ 提交于 2019-11-30 02:47:40
前言...... Akka是一个构建在JVM上,基于Actor模型的的并发框架,为构建伸缩性强,有弹性的响应式并发应用提高更好的平台。本文主要是个人对Akka的学习和应用中的一些理解。 Actor模型 Akka的核心就是Actor,所以不得不说Actor,Actor模型我通俗的举个例子,假定现实中的两个人,他们只知道对方的地址,他们想要交流,给对方传递信息,但是又没有手机,电话,网络之类的其他途径,所以他们之间只能用信件传递消息,很像现实中的的邮政系统,你要寄一封信,只需根据地址把信投寄到相应的信箱中,具体它是如何帮你处理送达的,你就不需要了解了,你也有可能收到收信人的回复,这相当于消息反馈。上述例子中的信件就相当于Actor中的消息,Actor与Actor之间只能通过消息通信。当然Actor模型比这要复杂的多,这里主要是简洁的阐述一下Actor模型的概念。 Akka中Actors模型 对并发模型进行了更高的抽象 异步、非阻塞、高性能的事件驱动编程模型 轻量级事件处理(1GB内存可容纳百万级别个Actor) 为什么Actor模型是一种处理并发问题的解决方案? 一开始我也不怎么理解,脑子里的一贯思维是处理并发问题就是如何保证共享数据的一致性和正确性,为什么会有保持共享数据正确性这个问题呢?无非是我们的程序是多线程的,多个线程对同一个数据进行修改,若不加同步条件,势必会造成数据污染

Alternatives to using “var” for state with actors?

强颜欢笑 提交于 2019-11-30 02:27:19
I have found myself using vars fairly often with akka actors to maintain state. For example, if I my actor needs to maintain a list of items, I might do something like: class ListActor extends Actor{ var xs : List[Int] = List() def receive = { case x : Int => xs = x :: xs } } Using the mutable variable seems to go against the spirit of Scala. Alternatively I have used this: class ListActor2 extends Actor{ import context._ def collect_ints(accu : List[Int]) : Receive = { case x : Int => become(collect_ints(x :: accu)) } def receive = collect_ints(Nil) } I like how this looks more, but do I have

How can i check if an Akka actor exists (akka 2.2)?

两盒软妹~` 提交于 2019-11-30 00:11:19
I have a java object which is not an actor which selects actors from an actor system with actorSelection(Path)). It is possible, that the selected actor does not exist in the system. In the Java Api ask() does not exist for ActorSelection, so I can not send and Identify message to the actor selection and use the sender of the response. I tried to solve the problem by sending the message to the actor anyway via the actor selection and then reacting to the deadletter. But I don't get any deadletters. How can I check with the ActorSelection if the actor is alive or does not exist? ActorSystem

Any good implementation of Actors for C#? [closed]

家住魔仙堡 提交于 2019-11-29 19:04:36
Is there any good implementation of actors concurrency model for .net/c#? I have to optimize a c# routine and i think that actors model fits perfectly as a solution for my problem. Unfortunately i have experience only with scala implementation. alex25 You should have a look at MS Concurrency & Coordination Runtime (CCR) , and the Decentralized Software Services (DSS) , part of Robotic Studio . These frameworks would allow you develop loosely coupled services that fulfill most of the actor-approach requirements. Axum would be the best fit, unfortunately it's still in some sort of alpha/beta

What's the difference of the Akka's Actor with Scala's Actor model

╄→гoц情女王★ 提交于 2019-11-29 18:59:13
I found there is also an Akka actor model, so I am wondering what's the difference between the Akka's Actor and Scala's Actor model? Alexey Romanov Well, there isn't. There is just Actor model, and Akka actors and Scala actors are two implementations of that model. All Actor model says that your concurrency primitives are actors, which can: receive a message and decide what to do next depending on the content of the message, including: send messages to any actors they know about create new actors and provides certain guarantees, e.g.: any actor will only handle a single message at a time

并发编程模型小结

隐身守侯 提交于 2019-11-29 14:06:42
1. 临界区加排他锁(Go sync.Mutex.Lock()) 如果并发量大,锁竞争激烈,会导致性能开销大 2. 读多写少场景,使用读写锁(Go sync.Mutex.RLock()) 支持并发读,但写锁会block住读和写,读多场景性能会好很多 3. 对计数使用CAS操作(Go sync.atomic.CompareAndSwapInt64()) CAS由CPU原子指令实现。是一种无锁结构,由于消耗的CPU指令周期少,性能要优于锁结构 4. actor并发模型 Erlang和scala akka使用的并发模型。一般并发线程通信有两种实现模型:共享内存和消息传递。共享内存最大的问题在于条件竞争,还容易产生死锁等问题。 actor是一种消息传递实现并发模型,定义了actor,每个actor有一个mail box,负责接收消息。消息只能顺序的放到邮箱中,由actor处理 5. CSP模型 Golang使用的是CSP并发模型,与actor唯一区别是没有mail box。代替使用channel进行消息传递,类似于linux的命名管道 6. SMT软件事务内存 参考数据库事务的实现,保证操作的ACID特性。通过内存日志实现对共享资源操作的原子性,commit或abort。但由于维护日志的开销,该模型的性能要低于锁。但其优势是可以极大简化多线程编程模型,不会产生诸如死锁等问题。