akka

Parallel File Processing: What are recommended ways?

妖精的绣舞 提交于 2020-01-03 16:55:36
问题 This is by large combination of design and code problem. Use Case - Given many log files in range (2MB - 2GB), I need to parse each of these logs and apply some processing, generate Java POJO . - For this problem, lets assume that we have just 1 log file - Also, the idea is to making best use of System. Multiple cores are available. Alternative 1 - Open file (synchronous), read each line, generate POJO s FileActor -> read each line -> List<POJO> Pros : simple to understand Cons : Serial

Setting up Akka with Eclipse

醉酒当歌 提交于 2020-01-03 10:56:30
问题 I am trying to get a simple Akka program building with Eclipse and Scala. I used g8 to create the sbt project with Akka(g8 typesafehub/akka-scala-sbt) and then sbteclispe to create the Eclipse project. When I import the project into Eclipse I'm given errors saying I am missing Akka. Is there any way that I can build an Akka project with Eclipse? 回答1: The simplest thing is to add the sbteclipse plugin to your Sbt build. It automatically generates project files for Eclipse, so that you can

When is it safe to block in an Akka 2 actor?

微笑、不失礼 提交于 2020-01-03 04:48:28
问题 I know that it is not recommended to block in the receive method of an actor, but I believe it can be done (as long as it is not done in too many actors at once). This post suggests blocking in preStart as one way to solve a problem, so presumably blocking in preStart is safe. However, I tried to block in preRestart (not preStart ) and everything seemed to just hang - no more messages were logged as received. Also, in cases where it is not safe to block, what is a safe alternative? 回答1: It's

Reply is not transmitted back to the 'client'-actor

丶灬走出姿态 提交于 2020-01-02 10:02:58
问题 I've an unexpected behavior when using remote actors. I've a server and a 'client'. The client sends a message to the server actor and the server replies. When I use the '?' operator everything works as expected. I get the answer back from the server. The server: class HelloWorldActor extends Actor { def receive = { case msg => self reply (msg + " World") } } object Server extends App{ Actor.remote.start("localhost",2552); Actor.remote.register("hello-service",Actor.actorOf[HelloWorldActor])

Maven Error No POM in this Project when performing archetype:generate

浪子不回头ぞ 提交于 2020-01-02 03:12:09
问题 I am trying my hands on the Akka Pi java tutorials I am trying to creaate a maven project as stated in the tutorial but any time I enter the command to create a maven project I get an error. Below are the command and the Error. C:\Program Files\akka-2.0.2>mvn archetype:generate \ C:\Program Files\akka-2.0.2>mvn archetype:generate \ [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] -----------------------

Akka actor lookup or dependency injection

懵懂的女人 提交于 2020-01-02 02:32:09
问题 I'm just starting to work with Akka and I can't decide if I should use dependency injection (like cake pattern) or actor lookup in order to decouple the actors from each others. What is the preferred method? 回答1: You should prefer to introduce actors to each other, which means to send an ActorRef in or with a message or to pass it into a constructor. The latter may involve the cake pattern of you so choose, but lookup is much more expensive and therefore you should use real ActorRef whenever

SLF4J: Class path contains multiple SLF4J bindings. message printed on console

自闭症网瘾萝莉.ら 提交于 2020-01-02 01:18:12
问题 I want to print logs on console and also write them in a file. In my scala project using akka loggers here is my build.sbt libraryDependencies ++= Seq("org.mongodb" %% "casbah" % "2.8.0", "org.slf4j" % "slf4j-simple" % "1.7.12", "org.elasticsearch" % "elasticsearch" % "1.5.0", "org.scalatest" %% "scalatest" % "2.2.1" % "test" withSources() withJavadoc(), "org.easymock" % "easymock" % "3.1" withSources() withJavadoc(), "org.mockito" % "mockito-all" % "1.9.5", "com.typesafe.akka" %% "akka-actor

Make Akka aware of Play's logback configuration

元气小坏坏 提交于 2020-01-01 09:28:11
问题 How do I make Akka aware of Play's logback config (application-logger.xml)? In my case it is completely ignored: The log is ONLY printed to stdout. I expect it to be logged to the File-Appender defined in application-logger.xml It does not make a difference if I rename application-logger.xml to logback.xml. Actor-class: class Dispatcher extends Actor with ActorLogging { // prints to stdout ONLY: log.error("[akka-logger] dispatch started...") } conf/application.conf: play { akka { #log-config

Handle Akka stream's first element specially

时光总嘲笑我的痴心妄想 提交于 2020-01-01 09:12:12
问题 Is there an idiomatic way of handling Akka stream's Source first element in a special way? What I have now is: var firstHandled = false source.map { elem => if(!firstHandled) { //handle specially firstHandled = true } else { //handle normally } } Thanks 回答1: While I would generally go with Ramon's answer, you could also use prefixAndTail, with a prefix of 1, together with flatMapConcat to achieve something similar: val src = Source(List(1, 2, 3, 4, 5)) val fst = Flow[Int].map(i => s"First: $i

Testing Akka actors that mixin Stash with TestActorRef

我们两清 提交于 2020-01-01 08:39:07
问题 I'm running into a problem with an actor that extends Stash and which works perfectly fine when instantiating it with actorOf in a simple ActorSystem. Now I would actually like to write some tests for my stashing actors before using them in my program. But I cannot figure out a way to use an TestActorRef with this actor in my test suite. The code that works looks like this: import akka.actor.{Stash, Actor, ActorSystem, Props} import com.typesafe.config.ConfigFactory object StashTest { val