How to restrict actor messages to specific types?

Then you’d have to encode the message type into the Actor ref, which would drastically decrease the value of something like the ActorRegistry. Also, with powerful mechanics like “become” (which is fundamental to the actor model) typing the messages is less valuable. Since Akka doesn’t leak memory when a message is not matched to the … Read more

Akka Kill vs. Stop vs. Poison Pill?

Both stop and PoisonPill will terminate the actor and stop the message queue. They will cause the actor to cease processing messages, send a stop call to all its children, wait for them to terminate, then call its postStop hook. All further messages are sent to the dead letters mailbox. The difference is in which … Read more

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

You need a Flow: import akka.stream.OverflowStrategy.fail import akka.stream.scaladsl.Source import akka.stream.scaladsl.{Sink, Flow} case class Weather(zip : String, temp : Double, raining : Boolean) val weatherSource = Source.actorRef[Weather](Int.MaxValue, fail) val sunnySource = weatherSource.filter(!_.raining) val ref = Flow[Weather] .to(Sink.ignore) .runWith(sunnySource) ref ! Weather(“02139”, 32.0, true) Remember this is all experimental and may change!

Is it possible to Autoscale Akka

If you consider a project like hseeberger/constructr and its issue 179, a native Akka solution should be based on akka/akka-management: This repository contains interfaces to inspect, interact and manage various Parts of Akka, primarily Akka Cluster. Future additions may extend these concepts to other parts of Akka. There is a demo for kubernetes.

How to schedule task daily + onStart() in Play 2.0.4?

Scheduler tasks should be placed only in Global class. Create two tasks, schedule only once first with initialDelay = 0 milliseconds. For the second task, you need to calculate seconds between current DateTime and next planned occurrence (ie. tomorrow at 8:00 o’clock) using common date/time classes, then set this difference as initialDelay and also set … Read more

How to create a Source that can receive elements later via a method call?

There are three ways this can be achieved: 1. Post Materialization with SourceQueue You can use Source.queue that materializes the Flow into a SourceQueue: case class Weather(zipCode : String, temperature : Double, raining : Boolean) val bufferSize = 100 //if the buffer fills up then this strategy drops the oldest elements //upon the arrival of … Read more

No configuration setting found for key ‘akka.version’

It seems that your problem is bundling into a jar-with-dependencies, which causes problems with Akka, as described in the documentation: Warning 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 by the configuration and loaded. Unfortunately this also means that if you … Read more

sender inside a future

You are making a very common mistake of “closing over mutable state”. The closure you pass to onComplete does not make a copy of this.sender, so when your onComplete gets called, you are sending the message to whatever this.sender happens to point to at that time, not what it pointed to when you created the … Read more