import akka.actor.Actor
class MyActor extends Actor {..}
val system = ActorSystem("MySystem")
In my classpath, I have no package called "akka". I do see instead scala.actors
, but it doesn't seem deprecated.
So, in which way are Akka Actors "part of the distribution"?
If this is, indeed, the case, then am I still supposed to add the "akka-actor_2.10" library as a dependency?
If so, do I use akka.Actor or the non-deprecated scala.actors.Actor ?
Akka is written in Scala, with language bindings provided for both Scala and Java. Akka's approach to handling concurrency is based on the Actor Model. In an actor-based system, everything is an actor, in much the same way that everything is an object in object-oriented design.
The Actor Model provides a higher level of abstraction for writing concurrent and distributed systems. It alleviates the developer from having to deal with explicit locking and thread management, making it easier to write correct concurrent and parallel systems.
An actor processes messages sequentially and (in Akka, at least) presents a single-threaded illusion (that is to say that under the hood, the dispatcher may execute the actor's logic on different threads from message to message, but from the actor's perspective there's only one thread).
This is a bit of a tricky problem, because Akka actors are started asynchronously when they're passed into the actorOf method using a Props . At the ActorSystem level of your application, you create actors by calling the system. actorOf method. Within an actor, you create a child actor by calling the context.
In scala 2.9.2 scala actors was part of scala-library.jar.
If you download a scala-2.10.0 distribution it there are no actors in scala-library and both akka-actors.jar and scala-actors.jar are supplied.
The latter is present for backwards compatibility and will be removed in a future major release.
akka-actors is the replacement and what you should use for any new development (and look to move anything using scala-actors across when possible).
If you have no current code in your project using actors you should probably reconfigure your project's dependencies to remove org.scala-lang:scala-actors:2.10.0 and instead depend on com.typesafe.akka:akka-actors_2.10:2.1.0 if you want to use actors.
I am not sure why there's no deprecation annotation on the classes in scala-actors in 2.10.0 but I believe it's to be added in 2.10.1.
You can find more info on the migration guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With