akka

Akka stream Source.queue hangs when using fail overflow strategy

时光总嘲笑我的痴心妄想 提交于 2020-01-05 08:18:24
问题 The following Scala snippet doesn't seem to return: val queue = Source.queue[Unit](10, OverflowStrategy.fail) .throttle(1, 1 second, 1, ThrottleMode.shaping) .to(Sink.ignore) .run() Await.result( (1 to 15).map(_ => queue.offer(())).last, Duration.Inf) Is this a bug in Akka streams or am I doing something wrong? EDIT: just to circle back, this bug was opened and accepted in Akka: https://github.com/akka/akka/issues/23078 回答1: This program gives more insight into what happens here: import akka

Akka stream Source.queue hangs when using fail overflow strategy

醉酒当歌 提交于 2020-01-05 08:18:02
问题 The following Scala snippet doesn't seem to return: val queue = Source.queue[Unit](10, OverflowStrategy.fail) .throttle(1, 1 second, 1, ThrottleMode.shaping) .to(Sink.ignore) .run() Await.result( (1 to 15).map(_ => queue.offer(())).last, Duration.Inf) Is this a bug in Akka streams or am I doing something wrong? EDIT: just to circle back, this bug was opened and accepted in Akka: https://github.com/akka/akka/issues/23078 回答1: This program gives more insight into what happens here: import akka

Compilation error when testing non blocking Redis client (Fyrie) on Play Framework 2.1

白昼怎懂夜的黑 提交于 2020-01-05 08:07:51
问题 when I try to compile the following code import play.api._ import play.api.mvc._ import scala.collection.mutable.StringBuilder import net.fyrie.redis.RedisClient import net.fyrie.redis.RedisClientConfig //import akka.dispatch._ //import akka.dispatch.Future object Application extends Controller { // val rd: RedisClient = new RedisClient("localhost", 6379, new RedisClientConfig(1, true, true, 50 to 100))(akka.actor.ActorSystem.create) val rd = RedisClient.apply("localhost", 6379, new

Akka: waiting for multiple messages

血红的双手。 提交于 2020-01-05 04:41:04
问题 Hi akka gurus:) Can you guide me in this one? What I'm trying to do - Actor A asks Actor B for a message and wait's for one to arrive back. But, somehow Actor B gives back to A not one message, but 4 of them. Actor A Future completes properly, but 3 of rest messages are counted as dead letters. Why? Is this right? I mean, Actor A has a proper handler, why the letters are dead then? :-( [INFO] [11/22/2013 22:00:38.975] [ForkJoinPool-2-worker-7] [akka://actors/user/a] Got result pong [INFO] [11

Execute some logic asynchronously in spray routing

纵然是瞬间 提交于 2020-01-05 04:36:11
问题 Here is my simple routing application: object Main extends App with SimpleRoutingApp { implicit val system = ActorSystem("my-system") startServer(interface = "0.0.0.0", port = System.getenv("PORT").toInt) { import format.UsageJsonFormat._ import spray.httpx.SprayJsonSupport._ path("") { get { complete("OK") } } ~ path("meter" / JavaUUID) { meterUUID => pathEnd { post { entity(as[Usage]) { usage => // execute some logic asynchronously // do not wait for the result complete("OK") } } } } } }

Akka/Java getContext().become with parameter?

青春壹個敷衍的年華 提交于 2020-01-04 02:15:08
问题 In Akka/Scala one is able to pass parameters to the custom receive function, so it is possible to pass the whole actor state through params, without using mutable variables. context.become(myCustomReceive(param1, param2)) But in Java Api you can pass only Procedure which gets the received message as the only param getContext().become( new Procedure<Object> { public void apply(Object param) throws Exception { // ... } } Is there a clean way to do the same trick in Java? 回答1: I would do it like

detecting failure from remote nodes from an akka router

北城以北 提交于 2020-01-04 02:14:08
问题 Lets say I have a router which is configured to create actors on multiple remote nodes. Perhaps I have a configuration like this: akka { actor { deployment { /fooRouter { router = round-robin resizer { lower-bound = 2 upper-bound = 10 } target { nodes = ["akka://mana@10.0.1.1:2555", "akka://mana@10.0.1.2:2555"] } } } } If we pretend that one of these nodes, 10.0.1.1, for some reason, has lost connectivity to the database server, so all messages passed to it will result in failure. Is there

Why isn't my akka logging working inside of play

╄→гoц情女王★ 提交于 2020-01-04 01:21:06
问题 My logging is working fine from within my play code, but the akka code I have isn't logging to file/stdout. class EmailActor extends Actor with ActorLogging { import EmailActor._ log.info("email actor hatched..") ... } When I create this actor I don't see the logging entries in either the log file or stdout. I have the default application.conf from this activator template: https://github.com/playframework/play-scala/blob/master/conf/logback.xml Do I need to modify my logback file with some

Why is Actor.receive a partial function?

两盒软妹~` 提交于 2020-01-03 19:41:50
问题 Why is Actor.receive a partial function? I can always have a regular function with match expression instead of it. 回答1: It is a PartialFunction to capture the possibility of a message being handled or unhandled by the Actor . An unhandled message will not make the Actor fail with a MatchError spawn an UnhandledMessage event to the event stream More info here. 回答2: One reason would be that the partial function has isDefinedAt method, which allows Akka to check if the message can be handled

Akka Actors fails, VerifyError: Inconsistent stackmap frames at branch target

谁说我不能喝 提交于 2020-01-03 18:15:07
问题 I have a Java application where I use Akka Typed Actors. The code has no errors in Eclipse, but when I start my application it crashes and prints this error: Exception in thread "main" java.lang.VerifyError: Inconsistent stackmap frames at branch target 266 in method com.example.actors.DBActor.getItems(Lorg/joda/time/DateTime;Lorg/joda/time/DateTime;)I at offset 170 at com.example.ui.Main$1.create(Main.java:31) at akka.actor.TypedActor$$anonfun$newInstance$3.apply(TypedActor.scala:677) at