FAQ Database Discussion Community


How to change HTTP status code of AsyncResult using Scalatra

scala,akka,scalatra
I have created a simple controller (the code below is obfuscated and simplified, assume ask returns a future with a message). What I am trying to do is change the HTTP code from something other than 200 (based on the actor result). When executing the code below I see the...

Akka consolidate concurrent database requests

scala,akka,spray
I want to be able to make concurrent requests to multiple data repositories and consolidate the results. I am trying to understand if my approach is at all valid or if there is a better way to approach this problem. I am definitely new to Akka / Spray / Scala...

Akka default vs runtime configuration

configuration,akka
I read the Akka v2.3.11 docs (Java, not Scala) and am still a bit confused about how configuration works. In section 2.9.2 ("Akka and JAR bundling") it states: Akka’s configuration approach relies heavily on the notion of every module/jar having its own reference.conf file, all of these will be discovered...

AKKA.NET Journals and Snapshot Store

persistence,akka,akka.net
Since I have not seen any example of using AKKA.NET Journals and Snapshot store, I assume I have to use both type of actors to implement an Event Store and CQRS. Is the Snapshot store expected to be updated every time when the actor state is changed, or should be...

Use case for Akka PoisonPill

akka,message,fault-tolerance
According to the Akka docs for PoisonPill: You can also send an actor the akka.actor.PoisonPill message, which will stop the actor when the message is processed. PoisonPill is enqueued as ordinary messages and will be handled after messages that were already queued in the mailbox. Although the usefulness/utility of such...

Is it possible to introduce more values to a materialized Akka Source in javadsl?

akka,akka-stream
I am trying to setup a stream with Akka's javadsl which handles the processing of new files in a folder. My question is: Should I re-run the RunnableFlow every time a new file is introduced, or is it possible to keep a RunnableFlow running indefinitaly while the stream is waiting...

java.lang.ClassCastException: Cannot cast akka.actor.Status$Success$ to akka.actor.Status$Success

akka,spray,spray-dsl
I am facing a weird exception java.lang.ClassCastException: Cannot cast akka.actor.Status$Success$ to akka.actor.Status$Success at java.lang.Class.cast(Class.java:3094) ~[na:1.7.0_45] at scala.concurrent.Future$$anonfun$mapTo$1.apply(Future.scala:405) ~[scala-library.jar:na] at scala.util.Success$$anonfun$map$1.apply(Try.scala:206) ~[scala-library.jar:na] at scala.util.Try$.apply(Try.scala:161) ~[scala-library.jar:na] at scala.util.Success.map(Try.scala:206) ~[scala-library.jar:na] Where the problem is the trailing $ - something...

Call Redis (or other db) from within Spray Route

scala,akka,spray,jedis
I am trying to figure out the best way to establish a Redis Pool and then make calls to Redis from within a Spray route. I want to make sure that I can use the connection pool for Redis connections. What would be the best way to instantiate the pool...

Akka & SLF4J Configuration

akka,slf4j
I read the Akka Logging tutorial and am still a bit confused as to how to get Akka working with SLF4J. I my understanding is correct, the general process is: Include the akka-slf4j module on the runtime classpath, which transitively pulls in slf4j-api Include an SLF4J backend on the runtime...

Spark,Akka,Storm Or RxJava [closed]

apache-spark,akka,storm,rx-java,spark-streaming
I have a use case where I get 10K to 15 K Messages/sec and it might be less than 5K also sometime and I push those into rabbitMQ now those messages I should parse,run some RE on that and do some sort aggregation and run some statistics. My product(the data...

Akka cluster and OpenShift

scala,akka,openshift
I'm new to Akka Clusters, however as I am understanding its documentation, I need to know at least one "seed node" to join an existing cluster. So when using clusters with OpenShift I would need to know if the current gear is the first node - then I would create...

Akka Java : create an actor with constructor taking parameters

java,akka
How could i create an actor with a customized constructor in java ? I have searched through the documentation but didn't found it. Here is my Actor: public class ResizePhotoActor extends UntypedActor { private int width; private int height; private String caption; public ResizePhotoActor(int width, int height, String caption) {...

Why Akka waits in this example?

akka
I am reading this Akka document, and I don't understand how the master wait for the Result message. At the bottom of the code, the master received a Calculate message // start the calculation master ! Calculate But the ! message is a tell message which means it is asynchronous....

Akka Gotchas when dealing with Futures

akka,future
Consider the following code bit: def receive = { case ComputeResult(itemId: Long) => //val originalSender = sender computeResult(itemId).map { result => originalSender ! result } } The computeResult results in a Future, so how would the introduction of a val prevent my from sending the result to the wrong sender?...

scala minecraft forgemod 'gradle runClient' gives runtime exception

scala,gradle,akka,minecraft,minecraft-forge
I'm trying to use akka inside my scala based mod. The when testing using "gradle runClient" it gives errors, best I can tell its missing the akka library at runtime. I don't see how to add akka library though. If it helps my project is here: https://github.com/tesract/NilCraft Any advice would...

Vaadin Web app with Computation heavy back-end

java,akka,vaadin7
I've developed a java application that analyses huge chunks of data from a database which results in a fairly long computation time and generates cvs files that i visualise with a charting library. So in order to avoid switching between a java-swing interface for user input and the visualisation in...

Getting context using AnnotationConfigApplicationContext in Akka Actor

spring,scala,akka
how do I get annotation context . I am looking at this code (copied from here) : case object Tick case object Get @Named class CountingService { def increment(count: Int) = count + 1 } @Named @Scope("prototype") class Counter @Inject() (countingService: CountingService) extends Actor { var count = 0 def...

Akka supervisor on stop of subordinate

scala,akka
I'm using Akka 2.3.11 and SupervisorStrategies for handling failures in the actors subordinates. However in addition to the supervision strategy I want to catch all "stops" (planned stops and such one which occur because of exceptions) of a subordinate to persist some information in the backends database. How can I...

How to tell why Play 2.4 is shutting down

logging,playframework-2.0,akka
I have Play 2.4 app that I'm currently running in development mode that I would like to move to production. The one hitch is that every other day or so of running, it just shuts down with no reason given. The message in the logs: 2015-05-14 03:06:11 -0600 [INFO] from...

akka.io receive line by line in 2.3

scala,tcp,akka
I'm using Akka 2.3 (since that's the version which comes with Play) and want to connect to some TCP socket. I'm aware of the akka.io package. However I can't see any way to process the received data as UTF-8 string line by line (against just receiving byte chunks). Searching the...

Akka thread safety with Futures

scala,akka
I have an actor that has a mutable state. In my receive method, I pattern match the messages and call some service that would return a Future. This Future would modify the state in my Actor instance. Is this state not thread safe? Since the Future would be executing in...

When to use Ask pattern in Akka

scala,akka
I'm started to learn Akka and in many official examples I see that request-response implemented using tell pattern. I.e. after worker made his work he sends result as new message back to sender. For example in this Pi approximation official tutorial shown how to design application where Master sends some...

Closing over java.util.concurrent.ConcurrentHashMap inside a Future of Actor's receive method?

performance,scala,thread-safety,akka,concurrenthashmap
I've an actor where I want to store my mutable state inside a map. Clients can send Get(key:String) and Put(key:String,value:String) messages to this actor. I'm considering the following options. Don't use futures inside the Actor's receive method. In this may have a negative impact on both latency as well as...

Sending behavior within Akka messages

java,akka,actor
Straight from the Akka docs: Actors are made to be containers for behavior and state, embracing this means to not routinely send behavior within messages (which may be tempting using Scala closures). One of the risks is to accidentally share mutable state between actors, and this violation of the actor...

Scala Actors - any suggestions when converting OOP based approach?

scala,oop,concurrency,akka,actor
I'm learning Scala and its Actors (via Akka lib) approach for handling concurrency. I'm having some questions while trying to convert typical OOP (think - Java style OOP) scenarios to Actor based ones. Let's consider the overused e-commerce example Webstore where Customers are making Orders that contain Items. If it...

Akka-Spray object marshall

json,scala,akka,marshalling,spray
I am experimenting with aka and spray, what I want to achieve is a simple object marshalling service. When I try to compile the code I get the following error : Error:(33, 18) could not find implicit value for parameter marshaller: spray.httpx.marshalling.Marshaller[ExampleApplication.Password] marshal(Password(randomString(8),i,0)) ^ Here is the code: import akka.actor.ActorSystem...

End-to-End Reactive Streaming RESTful service (a.k.a. Back-Pressure over HTTP)

scala,rest,akka,akka-stream,reactive-streams
I have been trying to clarify this question online for a while without success, so I will try to ask it here. I would like to find some resource or example where it shows how I can build an end-to-end fully back-pressured REST service + client. What I mean is...

Apache Camel File process is resulting in TypeConversion Error

scala,apache-camel,akka,akka-camel
I am using akka-camel to process files. My initial tests were working great, however when I started passing in actual xml files it is puking with type conversions. Here is my consumer (very simple, but puking at msg.bodyAs[String] class FileConsumer extends Consumer { def endpointUri = "file:/data/input/actor" val processor =...

Spray microservice assembly deduplicate

scala,sbt,akka,spray,microservices
I'm using this template to develop a microservice: http://www.typesafe.com/activator/template/activator-service-container-tutorial My sbt file is like this: import sbt._ import Keys._ name := "activator-service-container-tutorial" version := "1.0.1" scalaVersion := "2.11.6" crossScalaVersions := Seq("2.10.5", "2.11.6") resolvers += "Scalaz Bintray Repo" at "https://dl.bintray.com/scalaz/releases" libraryDependencies ++= { val containerVersion = "1.0.1" val configVersion = "1.2.1"...

Akka cluster: how to disable ClusterHeartbeat log

akka,akka-cluster
I'm playing a bit with an Akka cluster and I had a setup with 2 nodes. As expected, the two nodes chat each other to say that they are alive through the heartbeat. So every second I have a string like this in my log [debug] 15:42:10.683-a.c.ClusterHeartbeatSender: Cluster Node [akka.tcp://application@127.0.0.1:52650]...

akka dispatcher is not working

scala,configuration,akka,scala-2.11
I am writing the setting of my disptacher in addtional conf file and then loading it in application.conf but dispatcher is not working when i am giving the full path where the dispatcher located in my file i am also assuring that it dispatcher exsits or not by using if...

A future buried deep inside a chain of conditionals with a common “else” future

scala,akka
Pattern: A future is buried deep inside a chain of conditionals (if, map, etc.). For any scenario where this deep chain isn't satisfied, there is a single "else" future. To illustrate this, I've put together two examples. f which have conditionals separated out and hence needing the "else" future (e...

Akka clustering conflicts

akka,zeromq,distributed-computing
The Akka doc talks about a variety of seemingly inter-related Akka technologies without distinguishing much between them: Akka Networking Akka Remoting Akka Clustering The Akka ZeroMQ module My understanding is that "Akka Networking" is simply a module/lib that gives Akka the ability to speak to remote actor systems over TCP....

akka Actor unit testing using testkit

scala,unit-testing,akka,scalatest
There are many examples of using akka-testkit when the Actor being tested is responding to an ask: //below code was copied from example link val actorRef = TestActorRef(new MyActor) // hypothetical message stimulating a '42' answer val future = actorRef ? Say42 val Success(result: Int) = future.value.get result must be(42)...

Kamon JVM and OS Metrics in docker-grafana-graphite

java,scala,jvm,akka,akka-monitoring
Im trying to monitor my scala akka app in the docker-grafana-graphite using kamon. I can see the actors stats in the Kamon Dashboard but I can't see any data in the System dashboard (JVM & OS) Here is my build.sbt file: import com.typesafe.sbt.SbtAspectj._ name := """kinneret""" scalaVersion := "2.11.6" resolvers...

Convert existing SBT Scala application to Play

scala,playframework,sbt,akka
I've been working on building an application with Akka actors, and now that I've completed the actor-based business logic I'd like to give it a RESTful + websocket front-end. I'm trying to find instructions for how to setup Play within the context of an existing application. The only instructions I...

Stacktrace was: java.util.concurrent.TimeoutException: Futures timed out after [5000 milliseconds]

java,akka
This is what my actor looks like public final class DiskMonitorActor extends UntypedActor { private final File assetsDirectory; private final long thresholdPercentage; private final LoggingAdapter logging = Logging.getLogger(getContext().system(), this); public DiskMonitorActor(final File assetsDirectory, final long thresholdPercentage) { this.assetsDirectory = assetsDirectory; this.thresholdPercentage = thresholdPercentage; validateAssetsDirectory(); } public static Props props(final File...

Akka - Measure time of consumer

scala,akka,apache-kafka,consumer
I'm developing a system that pulls messages from a JMS(the consumer) and push it to a Kafka Topic(the producer). Since my consumer stays alive waiting for new messages arriving in the JMS queue and push it to Kafka, how can I effectively measure how many messages I can pull by...

Handling Events from a Service running in a Task in an AKKA.NET actor

c#,.net,multithreading,akka
I'm using the Prism framework for my WPF application. I have a producer service that runs in a Task and raises a CompositePresentationEvent when a file is found. I have an Akka actor that subscribes to the event. The actor's handler looks is simple, it looks like this: private void...

How to reference to the standard ActorSystem of play framework 2?

scala,playframework,akka,playframework-2.3
I wish to use the scheduler of akka, the examples are saying: system.scheduler.scheduleOnce() but there is no real information where the "system" should come from. The documentation is a little bit superficial and there was a lot of change (akka moved out of core scala). If I write val system...

Bug? Logger specified in config can't be loaded [akka.testkit.TestEventListener]?

java,maven,akka
As per docs, under (Expecting Log Messages), Be sure to exchange the default logger with the TestEventListener in your application.conf to enable this function: akka.loggers = [akka.testkit.TestEventListener] So, this works well when I put it in application.conf. My test work well @Test public void testActorForNonExistentLocation() throws Exception { final Map<String,...

Akka wait for computation of actor

akka
I would like to create a minimal example of an actor that sends off a message to an actor and then waits for the response of that actor. The reason for this example is that I want to use it in my thesis in context of disussing the usage other...

How can I create and use a stream of Pairs with Akka Streams for java?

java,stream,akka,akka-stream
Im trying to use the javadsl variant of Akka streams, and I seem to have hit a problem when I try to define a Flow which should take Pair elements. Say, for example, I have defined a Flow which accepts incoming Strings and Pairs it with a boolean stating wether...

Test actors: receive exactly N messages

scala,akka,actor,akka-testkit
I'm testing an application with Akka actors. I'm using Test probes. I want to verify that the probe receives EXACTLY 10 messages of the same type. One solution could be to write 10 times: probe.expectMsg(20 seconds, Done) But I would prefer a more general solution (for example I'd test my...

AKKA stops logging stack traces after a while

java,playframework,akka,slf4j
I've having a really strange issue with Akka and Play 2.3 (Java). I have a bunch of actors with very standard slf4J logging: public abstract class ScheduledJob extends UntypedActor { protected final LoggingAdapter logger = Logging.getLogger(getContext().system(), this); My akka.conf looks like this akka { loggers = ["akka.event.slf4j.Slf4jLogger"] loglevel = "DEBUG"...

Akka wait for Ack before stopping actor

scala,playframework,akka
I'm using Plays play.api.mvc.WebSockets in combination with akka.contrib.pattern.DistributedPubSub events and this works fine already. class SomeSocketActor(out: ActorRef) extends Actor { val mediator = DistributedPubSubExtension(context.system).mediator mediator ! Subscribe("some_group", self) def receive: Actor.Receive = { case SubscribeAck(Subscribe("some_group", None, `self`)) => context become ready } def ready: Actor.Receive = { // ... }...

Dynamic growth of `Actor`s vs Primal creation

scala,akka
In my project, I have defined groups of Actors called cells. Those cells process messages and operate basic calculations of some different kinds, one kind by small Actor type. What is the advantage(s) of growing those small Actors, then killing them once the job is done, rather than creating them...

Akka Future Respose to a Sender

scala,akka,future
I came across the following SIP: http://docs.scala-lang.org/sips/pending/spores.html As I was reading through, I came across this example: def receive = { case Request(data) => future { val result = transform(data) sender ! Response(result) } } There was a description below in that article: > Capturing sender in the above example...

Should I scale actors or actorsystems in AKKA?

akka,scaling
I have an EmailValidatorActor which sends a response to it's Sender about the validity of the email. I have one ActorSystem which contains many actors who use this EmailValidatorActor. My question is around scaling the same actor to serve other actors. If I have to scale the EmailValidatorActor to serve...

Hooking Akka DeadLetterActorRef

akka,dead-letter
According to the Akka docs, a DeadLetterActorRef is: the default implementation of the dead letters service to which Akka routes all messages whose destinations are shut down or non-existent. If I wanted to "tap into" dead letters sent after an actor is terminated, do I just somehow "hook" this DeadLetterActorRef...

How to use the Akka ask pattern without blocking

scala,asynchronous,akka,future
Hi I have a actor which is responsible for fetching data from a database, turning it into a list and sending it back to the sender. I am using the ask pattern to receive response from my actor, because I don't want to use await.result because this approach will block...

Split play project into parts

scala,akka,playframework-2.3
I am having some play framework web project that consist of 3 logical parts: an userweb , an admin area and akka actors. It's slowly growing up and I need to restart the production server for each small change. That's why I decided to split the project into 3 parts....

Meaning of ref@Ping in akka receive

scala,pattern-matching,akka,actor
I was surfing some code examples on akka and I found a particular example that I would like to be sure of the meaning: def receive: Receive = { case original@Ping(x) => // do stuff case _ => //do stuff } Ping is a case class used for message in...

Accessing the underlying ActorRef of an akka stream Source created by Source.actorRef

scala,akka,akka-stream
I'm trying to use the Source.actorRef method to create an akka.stream.scaladsl.Source object. Something of the form import akka.stream.OverflowStrategy.fail import akka.stream.scaladsl.Source case class Weather(zip : String, temp : Double, raining : Boolean) val weatherSource = Source.actorRef[Weather](Int.MaxValue, fail) val sunnySource = weatherSource.filter(!_.raining) ... My question is: how do I send data to...

How to keep Akka running all the time in Play 2.3

playframework,playframework-2.0,akka
I am using akka as a scheduler in a website written with Play framework 2.3. I kept the server running by using activator run in dev environment. And when I changed some files and tried to visit my website, the Play server will compile these changed files and reload the...

Akka router's routees sends Terminate message to itself

scala,akka
I have an actor which creates router. When all work done I want to stop current actor, stop it router and all routees. This is my code to stop the hierarchy: // stopping children context.children foreach context.stop // stopping current actor context.stop(self) But in log I'm getting messages like this:...

Retrieving state actors through worker actors in AKKA

akka,akka.net
I have three actors to handle a CQRS scenario. The ProductWorkerActor handles the command part, ProductQueryWorkerActor handles the query part and ProductStateActor handles the state part. The way I'm handling the query is by using: ProductQueryWorkerActor.Ask<ProductState>("give-me-product-state-for-product-1000") The code from ProductQueryWorkerActor: if (message == "give-me-product-state-for-product-1000") { var actor = Context.ActorSelection("akka://catalogSystem/user/productState/1000"); var...

Combining Spray Routing + Actor Pattern Matching

scala,akka,spray,akka-cluster
Following the Akka Cluster documentation, I have the Worker Dial-in example running. http://doc.akka.io/docs/akka/snapshot/java/cluster-usage.html So I've trying to integrate that with a spray routing. My idea is to have a cluster behind the scenes and through a http rest, call that service. So I have the following code. object Boot extends...

Spray route get response from child actor

scala,akka,spray
I am trying to figure out how I can setup a Master Actor that calls the appropriate children, in support of some spray routes where I am trying to emulate db calls. I am new to akka / spray, so just trying to gain a better understanding of how you...

scala + kafka does not send message with id

scala,akka,apache-kafka,kafka
I'm trying to send a message to Kafka through my actor and it does not work. The following code works new KeyedMessage[String, Array[Byte]]("my-topic", msg.message) This one doesn't... why? new KeyedMessage[String, Array[Byte]]("my-topic", msg.id, msg.message) or even new KeyedMessage[String, Array[Byte]]("my-topic", msg.id, null, msg.message) setting partition to null, forcing it to fill only...

Deserialization case class from ByteString

scala,serialization,akka,akka-io
I send case class using: tcpActor ! Tcp.Write(MyCaseClass(arg1: Class1, arg2: Class2).data) Then I received: case Tcp.Receive(data: ByteString) Is there any simple way to match data on MyCaseClass without using low level java serializer? ...

Akka messaging mechanisms by example

routing,akka,dispatcher,event-bus
I have a fair amount of Apache Camel (routing/mediation/orchestation engine; lightweight ESB) experience and am racking my brain trying to understand the difference between Akka: Dispatchers (Dispatcher, PinnedDispatcher, CallingThreadDispatcher) Routers Pools Groups Event Buses According to the docs: Dispatchers are: ...is what makes Akka Actors “tick”, it is the engine...

PersistentActor doesn't receive command

scala,persistence,akka
I have implemented the following PersistedActor import akka.actor._ import akka.persistence._ object TaskDispatcher { /** * Create Props for the actor */ def props(): Props = Props(new TaskDispatcher()) case class AddEndpoint(serverEndpoint: ActorRef, id: String) } class TaskDispatcher() extends PersistentActor with ActorLogging { import TaskDispatcher._ override def persistenceId = "task-dispatcher-persistence-ID" // Actor...

Java, Akka Actor and Bounded Mail Box

java,scala,akka
I have the following configuration in application.conf: bounded-mailbox { mailbox-type = "akka.dispatch.BoundedMailbox" mailbox-capacity = 100 mailbox-push-timeout-time = 3s } akka { loggers = ["akka.event.slf4j.Slf4jLogger"] loglevel = INFO daemonic = on } This is the way how I configured my actor public class MyTestActor extends UntypedActor implements RequiresMessageQueue<BoundedMessageQueueSemantics>{ @Override public void...

Does Akka Tcp support full-duplex communication?

multithreading,scala,sockets,tcp,akka
I've modified Echo server from https://github.com/akka/akka/blob/master/akka-docs/rst/scala/code/docs/io/EchoServer.scala#L96 case Received(data) => connection ! Write(data, Ack(currentOffset)) log.debug("same {}", sender.eq(connection)) // true buffer(data) That means incoming and outgoing messages are handled by the same actor. So a single working thread(that takes messages from a mailbox) will process read and write operations. In "classical" world...

Akka actorSelection vs actorOf Difference

scala,akka,actor
Is there a difference between these two? When I do: context.actorSelection(actorNameString) I get an ActorSelection reference which I can resolve using the resolveOne and I get back a Future[ActorRef]. But with an actorOf, I get an ActorRef immediately. Is there any other vital differences other than this? What might be...

How to get an actor from a deep graph in AKKA without ActorSelection?

akka,akka.net
This blog talks about to less use ActorSelection to select an actor. I have a CatalogActorSystem having 10000 product actors. All these actors have names which is really their ids. If I need to have access to the a product with id for example Product_5000 and should not use ActorSelection,...

Is AKKA trying to do in memory the same as Azure Service Bus Queue does on disk?

azure,akka,azureservicebus,akka.net
There are many benefits that an actor model like AKKA.net bring to the table like scalability, reactiveness, in memory-caching etc... When I tried to compare AKKA with Azure Service Bus Queues, I see pretty much the same primary benefits in Azure Service Bus except the benefit of in-memory caching. In...

Is there a way to tell that persistence backend is unreachable when working with persistent actor?

scala,akka,akka-persistence
I am working with a persistent actor in Scala using EventStore as a backend. Testing is specs2-based. During initialization of the spec class, inside the constructor of the other class that is being instantiated, I ask my actor for something and, if EventStore is not running, get Could not create...

Akka Ask & Futures

akka,spray
I'm an akka noob so apologies! I'm playing around with a system that uses Spray and Akka. I'm using the following code snippet to send a message to another actor. It uses ask which, from what I understand will return a future which is resolved in "mapTo" and "map". I...

Akka scheduling patterns

scala,akka
Consider classical "Word Count" program. It counts number of words in all files in some directory. Master receives some directory and splits job among Worker actors (each worker works with one file). This is pseudo-code: class WordCountWorker extends Actor { def receive = { case FileToCount(fileName:String) => val count =...

Drools rules not firing from Akka actor system

scala,rest,akka,drools,actor
We've built a Drools module in Scala which runs just fine when called separately, however now we're integrating it into an Akka actor system we've built to be able to fire rules via REST calls. For some reason no rules are firing whatsoever, even blank rules such as: rule "sample...

Spray Dead Letter msg

scala,akka,actor,spray
I'm trying to execute the following code trait CustomHttpService extends HttpService { import MyJsonProtocol._ import spray.httpx.SprayJsonSupport._ implicit def executionContext = actorRefFactory.dispatcher implicit val timeout = Timeout(5 seconds) val offerActor = actorRefFactory.actorOf(Props[OfferActor], "offer-actor") val defaultRoute = { path("offer" / JavaUUID) { uuid => get { respondWithMediaType(`application/json`) { complete { (offerActor ?...

Splitting inside a flow in Akka-Streams

akka,akka-stream
I am trying to come up with a solution to split an incoming String I am receiving into multiple Strings. I have been researching and it looks like in the previous versions of Akka-Streams there was a class Transformer that you could extend to do this kind of transformation. In...

Play - Akka: Actors testing

scala,playframework,akka,actor,akka-testkit
I've read about TestKit, TestActorRef and ImplicitSender provided by Akka. But I didn't found a way to check if a certain actor has received a certain message. I think that "expectMsg(Foo)" can be useful if the receiver-actor does "sender ! Foo". But my application is different: I have an actor...

Spray routing filter path parameter

scala,functional-programming,akka,spray
given this snippet of code val passRoute = (path("passgen" / IntNumber) & get) { length => complete { if(length > 0){ logger.debug(s"new password generated of length $length") newPass(length) } else { logger.debug("using default length 8 when no length specified") newPass(8) } } } How could I replace the if-else with...

What is the best way to work with akka from nodejs

node.js,scala,express,akka
I have an application frontend, implemented on angularjs + nodejs + express + socket.io. There's also a feature in a separate service. This service is written on akka. Here's the way of how the entire communication pipeline may look: [user enters a value] -> [angularjs gets the value and send...

Does Akka's BalancingPool dispatcher (BalancingDispatcher) have one thread per actor?

multithreading,routing,akka
BalancingDispatcher is now deprecated for assigning actors to directly but BalancingPool for routers uses BalancingDispatcher. As we don't configure the BalancingDispatcher directly, I'd like to know if the BalancingDispatcher is configured with threads equal to number of workers? If we're producing the BalancingPool in code instead of config, does this...

Chaining Akka Actors in a Spray Route

scala,akka,actor,spray
I have a restful API that receives an array of JSON messages that will be converted to individual Avro messages and then sent to Kafka. Inside the route, I call 3 different actors: 1) one actor goes out and retrieves the Avro schema from disk 2) then loop through the...

Akka router, Futures and blocking operation

scala,akka
I have a Master actor which creates Worker actors using router. Each Worker actor performs several HTTP connections. And from several sources I learnt that if actor doing some blocking operation, then it's better to wrap blocking operation into this construct: val resFut = future { blocking { executeQuery() }...

How to make available sourceThread and akkaTimestamp values in log events dispatched by non-Akka parts?

logging,akka,mdc
Our Akka project depends on some other non akka code. From within this code our way to get a logger is by calling org.slf4j.LoggerFactory.getLogger(ThisClass.class) I would like to have the real time and real thread when and where the event took place, included in the log print, so I fetch...

Akka persistence receiveRecover receives snapshots that are from other actor instances

akka,akka-persistence
I am experiencing unexpected behaviour when using Akka persistence. I am fairly new to Akka so apologies in advance if I have missed something obvious. I have an actor called PCNProcessor. I create an actor instance for every PCN id I have. The problem I experience is that when I...

In Scala, why is there no implementation for `Future.onComplete`?

scala,concurrency,akka,future
In the source code of Future module, I saw the definition of onComplete like this: /** When this future is completed, either through an exception, or a value, * apply the provided function. * * If the future has already been completed, * this will either be applied immediately or...

Play: stop WebSocket actor in case of failure

scala,playframework,websocket,akka
I'm using Play framework and Akka actors for WebSocket communication. I'm using tryAcceptWithActor method: def socket = WebSocket.tryAcceptWithActor[String, String] { request => Future.successful(request.session.get("user") match { case None => Left(Forbidden) case Some(_) => Right(MyWebSocketActor.props) }) } I would like MyWebSocketActor to Stop when it fails (e.g. throwing an Exception). Is this...

Does it make sense to watch(self) in akka?

akka
As far as I understand, context.watch simply delivers actor.Terminated message to watcher. I wanted it to be the last message that actor receives. Yet, I see that it is never delivered. I guess it can be because it is terminated and does not process messages anymore. As part of the...

Workload balancing between akka actors

multithreading,scala,web-crawler,akka,actor
I have 2 akka actors used for crawling links, i.e. find all links in page X, then find all links in all pages linked from X, etc... I want them to progress more or less at the same pace, but more often than not one of them becomes starved and...

How to get ActorRefs of all children of a RouterPool in Akka

scala,akka,akka-supervision
I create a RouterPool of an actor like this: val myActorPool = Akka.system.actorOf(RoundRobinPool(5).props(Props[MyActor]), "myActor") now i would like to access the ActorRef objects of the 5 children that are managed by this router. Is there some method call to retrieve that for all children? Or do i have to declare...

Concurrent for-comprehensions

scala,akka
According to this blog post there's a potential performance issue with for comprehensions. For example: for { a <- remoteCallA() b <- remoteCallB() } yield { (a, b) } has remoteCallB blocked until remoteCallA is completed. The blog post suggests that we do this instead: futureA <- remoteCallA() futureB <-...

akka: pattern for combining messages from multiple children

scala,concurrency,mapreduce,akka
Here's the pattern I have come across: An actor A has multiple children C1, ..., Cn. On receiving a message, A sends it to each of its children, which each do some calculation on the message, and on completion send it back to A. A would then like to combine...

spray akka deployment on webserver

java,scala,akka,spray,xsbt-web-plugin
I have an application built on spray + akka. using this guide: http://sysgears.com/articles/building-rest-service-with-scala/ It explains this example: https://github.com/oermolaev/simple-scala-rest-example The application is working just fine. But when trying to deploy on a webServer I didn't find a way to do that. I've tried to use xsbt-web-plugin to deploy on Tomcat, got...

How to unit test Dispatch Http in an Akka actor?

scala,unit-testing,akka
I have a Akka actor as follows; it receives a message and returns a HTTP response. I am having trouble testing the interaction with Dispatch Http, it is a nice library but seems difficult to test. class Service(serviceUrl:String) extends Actor with ActorLogging { implicit val ec = context .dispatcher override...

Importance of Akka Routers

scala,akka,actor
I have this lingering doubt in my mind about the importance of Akka Routers. I have used Akka Routers in the current project I am working on. However, I am a little confused about the importance of it. Out of the two below methods, which is more beneficial. having routers...

Akka: multiple dispatcher vs multiple actor system

akka,spray
I am wondering what would be the criteria to choose between having several actor systems in one application over having multiple dispatcher ? What are the consequence of multiple actor system vs multiple dispatcher ? ( or advantage)...

Modern Akka DI with Guice

java,akka,guice
Java 8, Guice 4.0 and Akka 2.3.9 here. I am trying to figure out how to annotate my actor classes with JSR330-style @Inject annotations, and then wire them all up via Guice. But literally every single article I have read (some examples below) either uses Scala code examples, a criminally-old...

Vaadin notification in UI with Akka actor

java,akka,actor,vaadin7
I'm working on integrating an akka actors based backend within a vaadin application. the problem i'm facing is i dare say simple (bear with me i'm a vaadin first timer :P). Project structure (simplified) 2 modules front and backend. my backEnd has an actor system that manages all the backend...

Bulkheading strategies for Akka actors

java,asynchronous,akka,blocking,future
I have a scenario where an important actor needs to make a call to a slow (15 - 20 seconds) remote system: // Non-actor code equivalent public Result makeSlowNetworkCall(Request request) { Result result = slowServiceClient.soooooSlow(request); // Could be up to 15 - 20 SECONDS (mehhhh) return result; } The Akka...

Spray.io log leaks sensitive information

scala,akka,spray
I'm using Spray client to consume a third-party API. Unfortunately, the API I'm consuming is not very secure and utilizes an authentication method using GET query parameters. Sometimes we're getting timeouts or connection issues which we know to deal with applicatively. The problem is that Spray logs this at a...

how to check my akka dispatchers defined in config file working or not

scala,configuration,akka,dispatcher
HI I am new to akka dispatchers i took help from the akka documentation I want to check either i tuned up the dispatcher correctly or not here is my applica.conf include "DirectUserWriteMongoActor" akka { loggers = ["akka.event.slf4j.Slf4jLogger"] loglevel = "DEBUG" } here is my DirectUserWriteMongoActor.conf akka { actor{ ###############################...

Typesafe Config: Load configuration from src/test/resources

java,configuration,akka,typesafe,typesafe-stack
This is a beginner question. So my app structure looks like src/main/java/... src/main/resources/application.conf src/test/java/... src/test/resources/module/test.module.conf application.conf location: mainLocation test.module.conf location: testLocation In my test, I do @Test public void testLoadConfig() { final Config config = ConfigFactory.parseResources("test.module.conf"); System.out.println(config); } and what I see Config(SimpleConfigObject({})) Surely something is not right, but I...

ActorNotFound Exception trying to run Spark 1.3.1 on windows 7

apache-spark,akka
We are at a road block trying to understand why Spark 1.3.1 doesn't work for a colleague of mine on his Windows 7 laptop. I have pretty much the same setup and everything works fine for me. I searched for the error message but still didn't find a resolution. Here...