[Scala][Akka] How to create supervised actors only for the single operation

At first, let's define the Supervisor:

class Supervisor extends Actor {

  override val supervisorStrategy =
    OneForOneStrategy() {
      case _: IllegalStateException =>
      case _: Exception => Stop

  override def receive: Receive = {
    case op: Operation => context.actorOf(Props(classOf[Worker], op))

I chose OneForOneStrategy which restarts or stops an actor in case of specified exception. It is worth noting that the operation is passed by the constructor of the newly created actor.

Secondly, let's take a look at Worker, which handles the operation:

class Worker(op: Operation) extends Actor {

  override def preStart(): Unit = {
    self ! op

  override def receive: Receive = {
    case op: Operation => op.execute()

As you can see, the operation is sent to the worker itself in the preStart method. This enables simple restarting or other supervision strategies to be done.

Any better solutions would be appreciated.

[Java][Maven] How to handle external jars with Maven

How to handle external jars with Maven

...the elegant way

If you've been struggling to add some jars to your maven project and maybe you've finished by adding them as a system scope dependency - you are in the right place!

After I spent some time on Stackoverflow, I decided to gather useful information and write a brief advice on how to deal with jar dependencies.

All you need to do is add and configure maven-install-plugin in your main pom.xml like this:


Then, Maven will install the configured jar in a prepare-package phase. The ${session.executionRootDirectory} variable points to the directory from which the maven command was executed.

Of course it would be better to have your own repository like Artifactory. But there isn't always such a possibility.

GitHub – Hoobie

Hubert Słojewski