Update docs

- use current version (2.0-SNAPSHOT) for easy search and replace
- some updates from akka-modules remerge
This commit is contained in:
Peter Vlugter 2011-05-26 17:14:42 +12:00
parent 89cb49366b
commit 046399c9df
11 changed files with 96 additions and 374 deletions

View file

@ -1,16 +0,0 @@
.. _add-on-modules:
Add-on Modules
==============
Akka Modules consist of add-on modules outside the core of Akka:
- ``akka-kernel-1.1.jar`` -- Akka microkernel for running a bare-bones mini application server (embeds Jetty etc.)
- ``akka-amqp-1.1.jar`` -- AMQP integration
- ``akka-camel-1.1.jar`` -- Apache Camel Actors integration (it's the best way to have your Akka application communicate with the rest of the world)
- ``akka-camel-typed-1.1.jar`` -- Apache Camel Typed Actors integration
- ``akka-scalaz-1.1.jar`` -- Support for the Scalaz library
- ``akka-spring-1.1.jar`` -- Spring framework integration
- ``akka-osgi-dependencies-bundle-1.1.jar`` -- OSGi support
Documentation for Akka Modules is located `here <http://akka.io/docs/akka-modules/snapshot/>`_.

View file

@ -4,7 +4,6 @@ Additional Information
.. toctree::
:maxdepth: 2
add-on-modules
articles
benchmarks
recipies

View file

@ -1,175 +1,6 @@
Getting Started Tutorial: First Chapter
=======================================
Introduction
------------
Welcome to the first tutorial on how to get started with Akka and Scala. We assume that you already know what Akka and Scala are and will now focus on the steps necessary to start your first project.
There are two variations of this first tutorial:
- creating a standalone project and run it from the command line
- creating a SBT (Simple Build Tool) project and running it from within SBT
Since they are so similar we will present them both.
The sample application that we will create is using actors to calculate the value of Pi. Calculating Pi is a CPU intensive operation and we will utilize Akka Actors to write a concurrent solution that scales out to multi-core processors. This sample will be extended in future tutorials to use Akka Remote Actors to scale out on multiple machines in a cluster.
We will be using an algorithm that is called "embarrassingly parallel" which just means that each job is completely isolated and not coupled with any other job. Since this algorithm is so parallelizable it suits the actor model very well.
Here is the formula for the algorithm we will use:
.. image:: ../images/pi-formula.png
In this particular algorithm the master splits the series into chunks which are sent out to each worker actor to be processed. When each worker has processed its chunk it sends a result back to the master which aggregates the total result.
Tutorial source code
--------------------
If you want don't want to type in the code and/or set up an SBT project then you can check out the full tutorial from the Akka GitHub repository. It is in the ``akka-tutorials/akka-tutorial-first`` module. You can also browse it online `here`__, with the actual source code `here`__.
__ https://github.com/jboner/akka/tree/master/akka-tutorials/akka-tutorial-first
__ https://github.com/jboner/akka/blob/master/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala
Prerequisites
-------------
This tutorial assumes that you have Java 1.6 or later installed on you machine and ``java`` on your ``PATH``. You also need to know how to run commands in a shell (ZSH, Bash, DOS etc.) and a decent text editor or IDE to type in the Scala code.
Downloading and installing Akka
-------------------------------
To build and run the tutorial sample from the command line, you have to download Akka. If you prefer to use SBT to build and run the sample then you can skip this section and jump to the next one.
Let's get the ``akka-1.1`` distribution of Akka core (not Akka Modules) from `http://akka.io/downloads <http://akka.io/downloads/>`_. Once you have downloaded the distribution unzip it in the folder you would like to have Akka installed in, in my case I choose to install it in ``/Users/jboner/tools/``, simply by unzipping it to this directory.
You need to do one more thing in order to install Akka properly: set the ``AKKA_HOME`` environment variable to the root of the distribution. In my case I'm opening up a shell, navigating down to the distribution, and setting the ``AKKA_HOME`` variable::
$ cd /Users/jboner/tools/akka-1.1
$ export AKKA_HOME=`pwd`
$ echo $AKKA_HOME
/Users/jboner/tools/akka-1.1
The distribution looks like this::
$ ls -l
total 16944
drwxr-xr-x 7 jboner staff 238 Apr 6 11:15 .
drwxr-xr-x 28 jboner staff 952 Apr 6 11:16 ..
drwxr-xr-x 17 jboner staff 578 Apr 6 11:16 deploy
drwxr-xr-x 26 jboner staff 884 Apr 6 11:16 dist
drwxr-xr-x 3 jboner staff 102 Apr 6 11:15 lib_managed
-rwxr-xr-x 1 jboner staff 8674105 Apr 6 11:15 scala-library.jar
drwxr-xr-x 4 jboner staff 136 Apr 6 11:16 scripts
- In the ``dist`` directory we have the Akka JARs, including sources and docs.
- In the ``lib_managed/compile`` directory we have Akka's dependency JARs.
- In the ``deploy`` directory we have the sample JARs.
- In the ``scripts`` directory we have scripts for running Akka.
- Finally ``scala-library.jar`` is the JAR for the latest Scala distribution that Akka depends on.
The only JAR we will need for this tutorial (apart from the ``scala-library.jar`` JAR) is the ``akka-actor-1.1.jar`` JAR in the ``dist`` directory. This is a self-contained JAR with zero dependencies and contains everything we need to write a system using Actors.
Akka is very modular and has many JARs for containing different features. The core distribution has seven modules:
- ``akka-actor-1.1.jar`` -- Standard Actors
- ``akka-typed-actor-1.1.jar`` -- Typed Actors
- ``akka-remote-1.1.jar`` -- Remote Actors
- ``akka-stm-1.1.jar`` -- STM (Software Transactional Memory), transactors and transactional datastructures
- ``akka-http-1.1.jar`` -- Akka Mist for continuation-based asynchronous HTTP and also Jersey integration
- ``akka-slf4j-1.1.jar`` -- SLF4J Event Handler Listener
- ``akka-testkit-1.1.jar`` -- Toolkit for testing Actors
We also have Akka Modules containing add-on modules outside the core of Akka. You can download the Akka Modules distribution from `<http://akka.io/downloads/>`_. It contains Akka core as well. We will not be needing any modules there today, but for your information the module JARs are these:
- ``akka-kernel-1.1.jar`` -- Akka microkernel for running a bare-bones mini application server (embeds Jetty etc.)
- ``akka-amqp-1.1.jar`` -- AMQP integration
- ``akka-camel-1.1.jar`` -- Apache Camel Actors integration (it's the best way to have your Akka application communicate with the rest of the world)
- ``akka-camel-typed-1.1.jar`` -- Apache Camel Typed Actors integration
- ``akka-scalaz-1.1.jar`` -- Support for the Scalaz library
- ``akka-spring-1.1.jar`` -- Spring framework integration
- ``akka-osgi-dependencies-bundle-1.1.jar`` -- OSGi support
Downloading and installing Scala
--------------------------------
To build and run the tutorial sample from the command line, you have to install the Scala distribution. If you prefer to use SBT to build and run the sample then you can skip this section and jump to the next one.
Scala can be downloaded from `http://www.scala-lang.org/downloads <http://www.scala-lang.org/downloads>`_. Browse there and download the Scala 2.9.0 release. If you pick the ``tgz`` or ``zip`` distribution then just unzip it where you want it installed. If you pick the IzPack Installer then double click on it and follow the instructions.
You also need to make sure that the ``scala-2.9.0/bin`` (if that is the directory where you installed Scala) is on your ``PATH``::
$ export PATH=$PATH:scala-2.9.0/bin
You can test your installation by invoking scala::
$ scala -version
Scala code runner version 2.9.0.final -- Copyright 2002-2011, LAMP/EPFL
Looks like we are all good. Finally let's create a source file ``Pi.scala`` for the tutorial and put it in the root of the Akka distribution in the ``tutorial`` directory (you have to create it first).
Some tools require you to set the ``SCALA_HOME`` environment variable to the root of the Scala distribution, however Akka does not require that.
Downloading and installing SBT
------------------------------
SBT, short for 'Simple Build Tool' is an excellent build system written in Scala. It uses Scala to write the build scripts which gives you a lot of power. It has a plugin architecture with many plugins available, something that we will take advantage of soon. SBT is the preferred way of building software in Scala and is probably the easiest way of getting through this tutorial. If you want to use SBT for this tutorial then follow the following instructions, if not you can skip this section and the next.
First browse to the `SBT download page <http://code.google.com/p/simple-build-tool/downloads/list>`_ and download the ``0.7.6.RC0`` distribution.
To install SBT and create a project for this tutorial it is easiest to follow the instructions on `this page <http://code.google.com/p/simple-build-tool/wiki/Setup>`_.
If you have created an SBT project then step into the newly created SBT project, create a source file ``Pi.scala`` for the tutorial sample and put it in the ``src/main/scala`` directory.
So far we only have a standard Scala project but now we need to make our project an Akka project. You could add the dependencies manually to the build script, but the easiest way is to use Akka's SBT Plugin, covered in the next section.
Creating an Akka SBT project
----------------------------
If you have not already done so, now is the time to create an SBT project for our tutorial. You do that by stepping into the directory you want to create your project in and invoking the ``sbt`` command answering the questions for setting up your project (just pressing ENTER will choose the default in square brackets)::
$ sbt
Project does not exist, create new project? (y/N/s) y
Name: Tutorial 1
Organization: Hakkers Inc
Version [1.0]:
Scala version [2.9.0]:
sbt version [0.7.6.RC0]:
Now we have the basis for an SBT project. Akka has an SBT Plugin making it very easy to use Akka is an SBT-based project so let's use that.
To use the plugin, first add a plugin definition to your SBT project by creating a ``Plugins.scala`` file in the ``project/plugins`` directory containing::
import sbt._
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val akkaRepo = "Akka Repo" at "http://akka.io/repository"
val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "1.1"
}
Now we need to create a project definition using our Akka SBT plugin. We do that by creating a ``project/build/Project.scala`` file containing::
import sbt._
class TutorialOneProject(info: ProjectInfo) extends DefaultProject(info) with AkkaProject {
val akkaRepo = "Akka Repo" at "http://akka.io/repository"
}
The magic is in mixing in the ``AkkaProject`` trait.
Not needed in this tutorial, but if you would like to use additional Akka modules beyond ``akka-actor``, you can add these as "module configurations" in the project file. Here is an example adding ``akka-remote`` and ``akka-stm``::
class AkkaSampleProject(info: ProjectInfo) extends DefaultProject(info) with AkkaProject {
val akkaSTM = akkaModule("stm")
val akkaRemote = akkaModule("remote")
}
So, now we are all set. Just one final thing to do; make SBT download the dependencies it needs. That is done by invoking::
> update
SBT itself needs a whole bunch of dependencies but our project will only need one; ``akka-actor-1.1.jar``. SBT downloads that as well.
Start writing the code
----------------------
@ -268,69 +99,3 @@ That's it. Now we are done.
But before we package it up and run it, let's take a look at the full code now, with package declaration, imports and all:
.. includecode:: examples/Pi.scala
Run it as a command line application
------------------------------------
If you have not typed in (or copied) the code for the tutorial as ``$AKKA_HOME/tutorial/Pi.scala`` then now is the time. When that's done open up a shell and step in to the Akka distribution (``cd $AKKA_HOME``).
First we need to compile the source file. That is done with Scala's compiler ``scalac``. Our application depends on the ``akka-actor-1.1.jar`` JAR file, so let's add that to the compiler classpath when we compile the source::
$ scalac -cp dist/akka-actor-1.1.jar tutorial/Pi.scala
When we have compiled the source file we are ready to run the application. This is done with ``java`` but yet again we need to add the ``akka-actor-1.1.jar`` JAR file to the classpath, and this time we also need to add the Scala runtime library ``scala-library.jar`` and the classes we compiled ourselves::
$ java -cp dist/akka-actor-1.1.jar:scala-library.jar:tutorial akka.tutorial.scala.first.Pi
AKKA_HOME is defined as [/Users/jboner/src/akka-stuff/akka-core], loading config from \
[/Users/jboner/src/akka-stuff/akka-core/config/akka.conf].
Pi estimate: 3.1435501812459323
Calculation time: 858 millis
Yippee! It is working.
If you have not defined an the ``AKKA_HOME`` environment variable then Akka can't find the ``akka.conf`` configuration file and will print out a ``Cant load akka.conf`` warning. This is ok since it will then just use the defaults.
Run it inside SBT
-----------------
If you used SBT, then you can run the application directly inside SBT. First you need to compile the project::
$ sbt
> update
...
> compile
...
When this in done we can run our application directly inside SBT::
> run
...
Pi estimate: 3.1435501812459323
Calculation time: 942 millis
Yippee! It is working.
If you have not defined an the ``AKKA_HOME`` environment variable then Akka can't find the ``akka.conf`` configuration file and will print out a ``Cant load akka.conf`` warning. This is ok since it will then just use the defaults.
The implementation in more detail
---------------------------------
To create our actors we used a method called ``actorOf`` in the ``Actor`` object. We used it in two different ways, one of them taking a actor type and the other one an instance of an actor. The former one (``actorOf[Worker]``) is used when the actor class has a no-argument constructor while the second one (``actorOf(new Master(..))``) is used when the actor class has a constructor that takes arguments. This is the only way to create an instance of an Actor and the ``actorOf`` method ensures this. The latter version is using call-by-name and lazily creates the actor within the scope of the ``actorOf`` method. The ``actorOf`` method instantiates the actor and returns, not an instance to the actor, but an instance to an ``ActorRef``. This reference is the handle through which you communicate with the actor. It is immutable, serializable and location-aware meaning that it "remembers" its original actor even if it is sent to other nodes across the network and can be seen as the equivalent to the Erlang actor's PID.
The actor's life-cycle is:
- Created -- ``Actor.actorOf[MyActor]`` -- can **not** receive messages
- Started -- ``actorRef.start()`` -- can receive messages
- Stopped -- ``actorRef.stop()`` -- can **not** receive messages
Once the actor has been stopped it is dead and can not be started again.
Conclusion
----------
We have learned how to create our first Akka project using Akka's actors to speed up a computation-intensive problem by scaling out on multi-core processors (also known as scaling up). We have also learned to compile and run an Akka project using either the tools on the command line or the SBT build system.
Now we are ready to take on more advanced problems. In the next tutorial we will build on this one, refactor it into more idiomatic Akka and Scala code, and introduce a few new concepts and abstractions. Whenever you feel ready, join me in the `Getting Started Tutorial: Second Chapter <TODO>`_.
Happy hakking.

View file

@ -41,7 +41,7 @@ Using Akka as a stand alone microkernel
---------------------------------------
Akka can also be run as a stand-alone microkernel. It implements a full
enterprise stack. See the :ref:`add-on-modules` for more information.
enterprise stack. See the :ref:`microkernel` for more information.
Using the Akka sbt plugin to package your application
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -56,7 +56,7 @@ To use the plugin, first add a plugin definition to your SBT project by creating
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val akkaRepo = "Akka Repo" at "http://akka.io/repository"
val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "1.1"
val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "2.0-SNAPSHOT"
}
Then mix the ``AkkaKernelProject`` trait into your project definition. For

View file

@ -66,7 +66,7 @@ To build and run the tutorial sample from the command line, you have to download
Akka. If you prefer to use SBT to build and run the sample then you can skip
this section and jump to the next one.
Let's get the ``akka-actors-1.1.zip`` distribution of Akka from
Let's get the ``akka-actors-2.0-SNAPSHOT.zip`` distribution of Akka from
http://akka.io/downloads/ which includes everything we need for this
tutorial. Once you have downloaded the distribution unzip it in the folder you
would like to have Akka installed in. In my case I choose to install it in
@ -77,10 +77,10 @@ You need to do one more thing in order to install Akka properly: set the
I'm opening up a shell, navigating down to the distribution, and setting the
``AKKA_HOME`` variable::
$ cd /Users/jboner/tools/akka-actors-1.1
$ cd /Users/jboner/tools/akka-actors-2.0-SNAPSHOT
$ export AKKA_HOME=`pwd`
$ echo $AKKA_HOME
/Users/jboner/tools/akka-actors-1.1
/Users/jboner/tools/akka-actors-2.0-SNAPSHOT
The distribution looks like this::
@ -98,32 +98,26 @@ The distribution looks like this::
The only JAR we will need for this tutorial (apart from the
``scala-library.jar`` JAR) is the ``akka-actor-1.1.jar`` JAR in the ``lib/akka``
``scala-library.jar`` JAR) is the ``akka-actor-2.0-SNAPSHOT.jar`` JAR in the ``lib/akka``
directory. This is a self-contained JAR with zero dependencies and contains
everything we need to write a system using Actors.
Akka is very modular and has many JARs for containing different features. The core distribution has seven modules:
- ``akka-actor-1.1.jar`` -- Standard Actors
- ``akka-typed-actor-1.1.jar`` -- Typed Actors
- ``akka-remote-1.1.jar`` -- Remote Actors
- ``akka-stm-1.1.jar`` -- STM (Software Transactional Memory), transactors and transactional datastructures
- ``akka-http-1.1.jar`` -- Akka Mist for continuation-based asynchronous HTTP and also Jersey integration
- ``akka-slf4j-1.1.jar`` -- SLF4J Event Handler Listener for logging with SLF4J
- ``akka-testkit-1.1.jar`` -- Toolkit for testing Actors
- ``akka-actor-2.0-SNAPSHOT.jar`` -- Standard Actors
- ``akka-typed-actor-2.0-SNAPSHOT.jar`` -- Typed Actors
- ``akka-remote-2.0-SNAPSHOT.jar`` -- Remote Actors
- ``akka-stm-2.0-SNAPSHOT.jar`` -- STM (Software Transactional Memory), transactors and transactional datastructures
- ``akka-http-2.0-SNAPSHOT.jar`` -- Akka Mist for continuation-based asynchronous HTTP and also Jersey integration
- ``akka-slf4j-2.0-SNAPSHOT.jar`` -- SLF4J Event Handler Listener for logging with SLF4J
- ``akka-testkit-2.0-SNAPSHOT.jar`` -- Toolkit for testing Actors
We also have Akka Modules containing add-on modules outside the core of
Akka. You can download the Akka Modules distribution from `<http://akka.io/downloads/>`_. It contains Akka
core as well. We will not be needing any modules there today, but for your
information the module JARs are these:
The Akka Microkernel distribution also includes these jars:
- ``akka-kernel-1.1.jar`` -- Akka microkernel for running a bare-bones mini application server (embeds Jetty etc.)
- ``akka-amqp-1.1.jar`` -- AMQP integration
- ``akka-camel-1.1.jar`` -- Apache Camel Actors integration (it's the best way to have your Akka application communicate with the rest of the world)
- ``akka-camel-typed-1.1.jar`` -- Apache Camel Typed Actors integration
- ``akka-scalaz-1.1.jar`` -- Support for the Scalaz library
- ``akka-spring-1.1.jar`` -- Spring framework integration
- ``akka-osgi-dependencies-bundle-1.1.jar`` -- OSGi support
- ``akka-kernel-2.0-SNAPSHOT.jar`` -- Akka microkernel for running a bare-bones mini application server (embeds Jetty etc.)
- ``akka-camel-2.0-SNAPSHOT.jar`` -- Apache Camel Actors integration (it's the best way to have your Akka application communicate with the rest of the world)
- ``akka-camel-typed-2.0-SNAPSHOT.jar`` -- Apache Camel Typed Actors integration
- ``akka-spring-2.0-SNAPSHOT.jar`` -- Spring framework integration
Downloading and installing Maven
@ -186,7 +180,7 @@ We also need to edit the ``pom.xml`` build file. Let's add the dependency we nee
<dependency>
<groupId>se.scalablesolutions.akka</groupId>
<artifactId>akka-actor</artifactId>
<version>1.1</version>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
@ -721,22 +715,22 @@ time. When that's done open up a shell and step in to the Akka distribution
(``cd $AKKA_HOME``).
First we need to compile the source file. That is done with Java's compiler
``javac``. Our application depends on the ``akka-actor-1.1.jar`` and the
``javac``. Our application depends on the ``akka-actor-2.0-SNAPSHOT.jar`` and the
``scala-library.jar`` JAR files, so let's add them to the compiler classpath
when we compile the source::
$ javac -cp lib/scala-library.jar:lib/akka/akka-actor-1.1.jar tutorial/akka/tutorial/first/java/Pi.java
$ javac -cp lib/scala-library.jar:lib/akka/akka-actor-2.0-SNAPSHOT.jar tutorial/akka/tutorial/first/java/Pi.java
When we have compiled the source file we are ready to run the application. This
is done with ``java`` but yet again we need to add the ``akka-actor-1.1.jar``
is done with ``java`` but yet again we need to add the ``akka-actor-2.0-SNAPSHOT.jar``
and the ``scala-library.jar`` JAR files to the classpath as well as the classes
we compiled ourselves::
$ java \
-cp lib/scala-library.jar:lib/akka/akka-actor-1.1.jar:tutorial \
-cp lib/scala-library.jar:lib/akka/akka-actor-2.0-SNAPSHOT.jar:tutorial \
akka.tutorial.java.first.Pi
AKKA_HOME is defined as [/Users/jboner/tools/akka-actors-1.1]
loading config from [/Users/jboner/tools/akka-actors-1.1/config/akka.conf].
AKKA_HOME is defined as [/Users/jboner/tools/akka-actors-2.0-SNAPSHOT]
loading config from [/Users/jboner/tools/akka-actors-2.0-SNAPSHOT/config/akka.conf].
Pi estimate: 3.1435501812459323
Calculation time: 822 millis

View file

@ -51,7 +51,7 @@ To build and run the tutorial sample from the command line, you have to download
Akka. If you prefer to use SBT to build and run the sample then you can skip
this section and jump to the next one.
Let's get the ``akka-actors-1.1.zip`` distribution of Akka from
Let's get the ``akka-actors-2.0-SNAPSHOT.zip`` distribution of Akka from
http://akka.io/downloads/ which includes everything we need for this
tutorial. Once you have downloaded the distribution unzip it in the folder you
would like to have Akka installed in. In my case I choose to install it in
@ -62,10 +62,10 @@ You need to do one more thing in order to install Akka properly: set the
I'm opening up a shell, navigating down to the distribution, and setting the
``AKKA_HOME`` variable::
$ cd /Users/jboner/tools/akka-actors-1.1
$ cd /Users/jboner/tools/akka-actors-2.0-SNAPSHOT
$ export AKKA_HOME=`pwd`
$ echo $AKKA_HOME
/Users/jboner/tools/akka-actors-1.1
/Users/jboner/tools/akka-actors-2.0-SNAPSHOT
The distribution looks like this::
@ -83,32 +83,26 @@ The distribution looks like this::
The only JAR we will need for this tutorial (apart from the
``scala-library.jar`` JAR) is the ``akka-actor-1.1.jar`` JAR in the ``lib/akka``
``scala-library.jar`` JAR) is the ``akka-actor-2.0-SNAPSHOT.jar`` JAR in the ``lib/akka``
directory. This is a self-contained JAR with zero dependencies and contains
everything we need to write a system using Actors.
Akka is very modular and has many JARs for containing different features. The core distribution has seven modules:
- ``akka-actor-1.1.jar`` -- Standard Actors
- ``akka-typed-actor-1.1.jar`` -- Typed Actors
- ``akka-remote-1.1.jar`` -- Remote Actors
- ``akka-stm-1.1.jar`` -- STM (Software Transactional Memory), transactors and transactional datastructures
- ``akka-http-1.1.jar`` -- Akka Mist for continuation-based asynchronous HTTP and also Jersey integration
- ``akka-slf4j-1.1.jar`` -- SLF4J Event Handler Listener for logging with SLF4J
- ``akka-testkit-1.1.jar`` -- Toolkit for testing Actors
- ``akka-actor-2.0-SNAPSHOT.jar`` -- Standard Actors
- ``akka-typed-actor-2.0-SNAPSHOT.jar`` -- Typed Actors
- ``akka-remote-2.0-SNAPSHOT.jar`` -- Remote Actors
- ``akka-stm-2.0-SNAPSHOT.jar`` -- STM (Software Transactional Memory), transactors and transactional datastructures
- ``akka-http-2.0-SNAPSHOT.jar`` -- Akka Mist for continuation-based asynchronous HTTP and also Jersey integration
- ``akka-slf4j-2.0-SNAPSHOT.jar`` -- SLF4J Event Handler Listener for logging with SLF4J
- ``akka-testkit-2.0-SNAPSHOT.jar`` -- Toolkit for testing Actors
We also have Akka Modules containing add-on modules outside the core of
Akka. You can download the Akka Modules distribution from `<http://akka.io/downloads/>`_. It contains Akka
core as well. We will not be needing any modules there today, but for your
information the module JARs are these:
The Akka Microkernel distribution also includes these jars:
- ``akka-kernel-1.1.jar`` -- Akka microkernel for running a bare-bones mini application server (embeds Jetty etc.)
- ``akka-amqp-1.1.jar`` -- AMQP integration
- ``akka-camel-1.1.jar`` -- Apache Camel Actors integration (it's the best way to have your Akka application communicate with the rest of the world)
- ``akka-camel-typed-1.1.jar`` -- Apache Camel Typed Actors integration
- ``akka-scalaz-1.1.jar`` -- Support for the Scalaz library
- ``akka-spring-1.1.jar`` -- Spring framework integration
- ``akka-osgi-dependencies-bundle-1.1.jar`` -- OSGi support
- ``akka-kernel-2.0-SNAPSHOT.jar`` -- Akka microkernel for running a bare-bones mini application server (embeds Jetty etc.)
- ``akka-camel-2.0-SNAPSHOT.jar`` -- Apache Camel Actors integration (it's the best way to have your Akka application communicate with the rest of the world)
- ``akka-camel-typed-2.0-SNAPSHOT.jar`` -- Apache Camel Typed Actors integration
- ``akka-spring-2.0-SNAPSHOT.jar`` -- Spring framework integration
Downloading and installing the Scala IDE for Eclipse
@ -173,7 +167,7 @@ If you are an `SBT <http://code.google.com/p/simple-build-tool/>`_ user, you can
lazy val eclipse = "de.element34" % "sbt-eclipsify" % "0.7.0"
val akkaRepo = "Akka Repo" at "http://akka.io/repository"
val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "1.1"
val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "2.0-SNAPSHOT"
}
and then update your SBT project definition by mixing in ``Eclipsify`` in your project definition::
@ -412,8 +406,8 @@ Run it from Eclipse
Eclipse builds your project on every save when ``Project/Build Automatically`` is set. If not, bring you project up to date by clicking ``Project/Build Project``. If there are no compilation errors, you can right-click in the editor where ``Pi`` is defined, and choose ``Run as.. /Scala application``. If everything works fine, you should see::
AKKA_HOME is defined as [/Users/jboner/tools/akka-actors-1.1]
loading config from [/Users/jboner/tools/akka-actors-1.1/config/akka.conf].
AKKA_HOME is defined as [/Users/jboner/tools/akka-actors-2.0-SNAPSHOT]
loading config from [/Users/jboner/tools/akka-actors-2.0-SNAPSHOT/config/akka.conf].
Pi estimate: 3.1435501812459323
Calculation time: 858 millis

View file

@ -63,10 +63,9 @@ Downloading and installing Akka
-------------------------------
To build and run the tutorial sample from the command line, you have to download
Akka. If you prefer to use SBT to build and run the sample then you can skip
this section and jump to the next one.
Akka. If you prefer to use SBT to build and run the sample then you can skipthis section and jump to the next one.
Let's get the ``akka-actors-1.1.zip`` distribution of Akka from
Let's get the ``akka-actors-2.0-SNAPSHOT.zip`` distribution of Akka from
http://akka.io/downloads/ which includes everything we need for this
tutorial. Once you have downloaded the distribution unzip it in the folder you
would like to have Akka installed in. In my case I choose to install it in
@ -77,10 +76,10 @@ You need to do one more thing in order to install Akka properly: set the
I'm opening up a shell, navigating down to the distribution, and setting the
``AKKA_HOME`` variable::
$ cd /Users/jboner/tools/akka-actors-1.1
$ cd /Users/jboner/tools/akka-actors-2.0-SNAPSHOT
$ export AKKA_HOME=`pwd`
$ echo $AKKA_HOME
/Users/jboner/tools/akka-actors-1.1
/Users/jboner/tools/akka-actors-2.0-SNAPSHOT
The distribution looks like this::
@ -98,32 +97,26 @@ The distribution looks like this::
The only JAR we will need for this tutorial (apart from the
``scala-library.jar`` JAR) is the ``akka-actor-1.1.jar`` JAR in the ``lib/akka``
``scala-library.jar`` JAR) is the ``akka-actor-2.0-SNAPSHOT.jar`` JAR in the ``lib/akka``
directory. This is a self-contained JAR with zero dependencies and contains
everything we need to write a system using Actors.
Akka is very modular and has many JARs for containing different features. The core distribution has seven modules:
- ``akka-actor-1.1.jar`` -- Standard Actors
- ``akka-typed-actor-1.1.jar`` -- Typed Actors
- ``akka-remote-1.1.jar`` -- Remote Actors
- ``akka-stm-1.1.jar`` -- STM (Software Transactional Memory), transactors and transactional datastructures
- ``akka-http-1.1.jar`` -- Akka Mist for continuation-based asynchronous HTTP and also Jersey integration
- ``akka-slf4j-1.1.jar`` -- SLF4J Event Handler Listener for logging with SLF4J
- ``akka-testkit-1.1.jar`` -- Toolkit for testing Actors
- ``akka-actor-2.0-SNAPSHOT.jar`` -- Standard Actors
- ``akka-typed-actor-2.0-SNAPSHOT.jar`` -- Typed Actors
- ``akka-remote-2.0-SNAPSHOT.jar`` -- Remote Actors
- ``akka-stm-2.0-SNAPSHOT.jar`` -- STM (Software Transactional Memory), transactors and transactional datastructures
- ``akka-http-2.0-SNAPSHOT.jar`` -- Akka Mist for continuation-based asynchronous HTTP and also Jersey integration
- ``akka-slf4j-2.0-SNAPSHOT.jar`` -- SLF4J Event Handler Listener for logging with SLF4J
- ``akka-testkit-2.0-SNAPSHOT.jar`` -- Toolkit for testing Actors
We also have Akka Modules containing add-on modules outside the core of
Akka. You can download the Akka Modules distribution from `<http://akka.io/downloads/>`_. It contains Akka
core as well. We will not be needing any modules there today, but for your
information the module JARs are these:
The Akka Microkernel distribution also includes these jars:
- ``akka-kernel-1.1.jar`` -- Akka microkernel for running a bare-bones mini application server (embeds Jetty etc.)
- ``akka-amqp-1.1.jar`` -- AMQP integration
- ``akka-camel-1.1.jar`` -- Apache Camel Actors integration (it's the best way to have your Akka application communicate with the rest of the world)
- ``akka-camel-typed-1.1.jar`` -- Apache Camel Typed Actors integration
- ``akka-scalaz-1.1.jar`` -- Support for the Scalaz library
- ``akka-spring-1.1.jar`` -- Spring framework integration
- ``akka-osgi-dependencies-bundle-1.1.jar`` -- OSGi support
- ``akka-kernel-2.0-SNAPSHOT.jar`` -- Akka microkernel for running a bare-bones mini application server (embeds Jetty etc.)
- ``akka-camel-2.0-SNAPSHOT.jar`` -- Apache Camel Actors integration (it's the best way to have your Akka application communicate with the rest of the world)
- ``akka-camel-typed-2.0-SNAPSHOT.jar`` -- Apache Camel Typed Actors integration
- ``akka-spring-2.0-SNAPSHOT.jar`` -- Spring framework integration
Downloading and installing Scala
@ -180,7 +173,7 @@ To use the plugin, first add a plugin definition to your SBT project by creating
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val akkaRepo = "Akka Repo" at "http://akka.io/repository"
val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "1.1"
val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "2.0-SNAPSHOT"
}
Now we need to create a project definition using our Akka SBT plugin. We do that by creating a ``project/build/Project.scala`` file containing::
@ -205,7 +198,7 @@ So, now we are all set. Just one final thing to do; make SBT download the depend
The first reload command is needed because we have changed the project definition since the sbt session started.
SBT itself needs a whole bunch of dependencies but our project will only need one; ``akka-actor-1.1.jar``. SBT downloads that as well.
SBT itself needs a whole bunch of dependencies but our project will only need one; ``akka-actor-2.0-SNAPSHOT.jar``. SBT downloads that as well.
Start writing the code
----------------------
@ -519,17 +512,17 @@ Run it as a command line application
If you have not typed in (or copied) the code for the tutorial as ``$AKKA_HOME/tutorial/Pi.scala`` then now is the time. When that's done open up a shell and step in to the Akka distribution (``cd $AKKA_HOME``).
First we need to compile the source file. That is done with Scala's compiler ``scalac``. Our application depends on the ``akka-actor-1.1.jar`` JAR file, so let's add that to the compiler classpath when we compile the source::
First we need to compile the source file. That is done with Scala's compiler ``scalac``. Our application depends on the ``akka-actor-2.0-SNAPSHOT.jar`` JAR file, so let's add that to the compiler classpath when we compile the source::
$ scalac -cp lib/akka/akka-actor-1.1.jar tutorial/Pi.scala
$ scalac -cp lib/akka/akka-actor-2.0-SNAPSHOT.jar tutorial/Pi.scala
When we have compiled the source file we are ready to run the application. This is done with ``java`` but yet again we need to add the ``akka-actor-1.1.jar`` JAR file to the classpath, and this time we also need to add the Scala runtime library ``scala-library.jar`` and the classes we compiled ourselves::
When we have compiled the source file we are ready to run the application. This is done with ``java`` but yet again we need to add the ``akka-actor-2.0-SNAPSHOT.jar`` JAR file to the classpath, and this time we also need to add the Scala runtime library ``scala-library.jar`` and the classes we compiled ourselves::
$ java \
-cp lib/scala-library.jar:lib/akka/akka-actor-1.1.jar:. \
-cp lib/scala-library.jar:lib/akka/akka-actor-2.0-SNAPSHOT.jar:. \
akka.tutorial.first.scala.Pi
AKKA_HOME is defined as [/Users/jboner/tools/akka-actors-1.1]
loading config from [/Users/jboner/tools/akka-actors-1.1/config/akka.conf].
AKKA_HOME is defined as [/Users/jboner/tools/akka-actors-2.0-SNAPSHOT]
loading config from [/Users/jboner/tools/akka-actors-2.0-SNAPSHOT/config/akka.conf].
Pi estimate: 3.1435501812459323
Calculation time: 858 millis

View file

@ -40,31 +40,19 @@ dependencies from the Akka Maven repository.
Modules
-------
Akka is split up into two different parts:
* Akka - The core modules. Reflects all the sections under :ref:`scala-api` and :ref:`java-api`.
* Akka Modules - The microkernel and add-on modules, described in :ref:`add-on-modules`.
Akka is very modular and has many JARs for containing different features. The core distribution has seven modules:
- ``akka-actor-1.1.jar`` -- Standard Actors
- ``akka-typed-actor-1.1.jar`` -- Typed Actors
- ``akka-remote-1.1.jar`` -- Remote Actors
- ``akka-stm-1.1.jar`` -- STM (Software Transactional Memory), transactors and transactional datastructures
- ``akka-http-1.1.jar`` -- Akka Mist for continuation-based asynchronous HTTP and also Jersey integration
- ``akka-slf4j-1.1.jar`` -- SLF4J Event Handler Listener
- ``akka-testkit-1.1.jar`` -- Toolkit for testing Actors
We also have Akka Modules containing add-on modules outside the core of Akka.
- ``akka-kernel-1.1.jar`` -- Akka microkernel for running a bare-bones mini application server (embeds Jetty etc.)
- ``akka-amqp-1.1.jar`` -- AMQP integration
- ``akka-camel-1.1.jar`` -- Apache Camel Actors integration (it's the best way to have your Akka application communicate with the rest of the world)
- ``akka-camel-typed-1.1.jar`` -- Apache Camel Typed Actors integration
- ``akka-scalaz-1.1.jar`` -- Support for the Scalaz library
- ``akka-spring-1.1.jar`` -- Spring framework integration
- ``akka-osgi-dependencies-bundle-1.1.jar`` -- OSGi support
Akka is very modular and has many JARs for containing different features.
- ``akka-actor-2.0-SNAPSHOT.jar`` -- Standard Actors
- ``akka-typed-actor-2.0-SNAPSHOT.jar`` -- Typed Actors
- ``akka-remote-2.0-SNAPSHOT.jar`` -- Remote Actors
- ``akka-stm-2.0-SNAPSHOT.jar`` -- STM (Software Transactional Memory), transactors and transactional datastructures
- ``akka-http-2.0-SNAPSHOT.jar`` -- Akka Mist for continuation-based asynchronous HTTP and also Jersey integration
- ``akka-slf4j-2.0-SNAPSHOT.jar`` -- SLF4J Event Handler Listener
- ``akka-testkit-2.0-SNAPSHOT.jar`` -- Toolkit for testing Actors
- ``akka-camel-2.0-SNAPSHOT.jar`` -- Apache Camel Actors integration (it's the best way to have your Akka application communicate with the rest of the world)
- ``akka-camel-typed-2.0-SNAPSHOT.jar`` -- Apache Camel Typed Actors integration
- ``akka-spring-2.0-SNAPSHOT.jar`` -- Spring framework integration
- ``akka-kernel-2.0-SNAPSHOT.jar`` -- Akka microkernel for running a bare-bones mini application server (embeds Jetty etc.)
How to see the JARs dependencies of each Akka module is described in the :ref:`dependencies` section. Worth noting
is that ``akka-actor`` has zero external dependencies (apart from the ``scala-library.jar`` JAR).
@ -82,7 +70,7 @@ The Akka Modules distribution includes the microkernel. To run the microkernel:
* Set the AKKA_HOME environment variable to the root of the Akka distribution.
* To start the kernel use the scripts in the ``bin`` directory and deploy all samples applications from ``./deploy`` dir.
More information is available in the documentation of the Microkernel in :ref:`add-on-modules`.
More information is available in the documentation of the :ref:`microkernel`.
Using a build tool
------------------
@ -107,14 +95,14 @@ Summary of the essential parts for using Akka with Maven:
<url>http://akka.io/repository/ </url>
</repository>
2) Add the Akka dependencies. For example, here is the dependency for Akka Actor 1.1:
2) Add the Akka dependencies. For example, here is the dependency for Akka Actor 2.0-SNAPSHOT:
.. code-block:: xml
<dependency>
<groupId>se.scalablesolutions.akka</groupId>
<artifactId>akka-actor</artifactId>
<version>1.1</version>
<version>2.0-SNAPSHOT</version>
</dependency>
@ -129,7 +117,7 @@ Summary of the essential parts for using Akka with SBT:
1) Akka has an SBT plugin which makes it very easy to get started with Akka and SBT.
The Scala version in your SBT project needs to match the version that Akka is built against. For Akka 1.1 this is
The Scala version in your SBT project needs to match the version that Akka is built against. For Akka 2.0-SNAPSHOT this is
Scala version 2.9.0.
To use the plugin, first add a plugin definition to your SBT project by creating project/plugins/Plugins.scala with:
@ -140,10 +128,10 @@ To use the plugin, first add a plugin definition to your SBT project by creating
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val akkaRepo = "Akka Repo" at "http://akka.io/repository"
val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "1.1"
val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "2.0-SNAPSHOT"
}
*Note: the plugin version matches the Akka version provided. The current release is 1.1.*
*Note: the plugin version matches the Akka version provided. The current release is 2.0-SNAPSHOT.*
2) Then mix the AkkaProject trait into your project definition. For example:

View file

@ -3,7 +3,7 @@ Release Notes
Changes listed in no particular order.
Current Development 1.1-SNAPSHOT
1.1
----------------------------------------
- **UPD** - improve FSM DSL: make onTransition syntax nicer (Roland Kuhn)

View file

@ -223,10 +223,15 @@ Same as with ``fold``, the execution will be done by the Thread that completes t
This is just a sample of what can be done, but to use more advanced techniques it is easier to take advantage of Scalaz, which Akka has support for in its akka-scalaz module.
Scalaz
^^^^^^
Akka also has a Scalaz module (:ref:`add-on-modules`) for a more complete support of programming in a functional style.
There is also an `Akka-Scalaz`_ project created by Derek Williams for a more
complete support of programming in a functional style.
.. _Akka-Scalaz: https://github.com/derekjw/akka-scalaz
Exceptions
----------

View file

@ -106,7 +106,7 @@ Add the Akka SBT plugin definition to your SBT project by creating a ``Plugins.s
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val akkaRepo = "Akka Repo" at "http://akka.io/repository"
val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "1.1-M1"
val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "2.0-SNAPSHOT"
}
Create a project definition ``project/build/Project.scala`` file containing::