<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-1353705672307703652</atom:id><lastBuildDate>Tue, 06 Mar 2018 08:59:31 +0000</lastBuildDate><category>Akka</category><category>Scala</category><category>Dependency Injection</category><category>Spring.NET</category><category>WCF</category><category>Active Directory</category><category>NUnit</category><category>Ruby</category><category>SOA</category><category>SVN</category><category>XNA</category><title>Ray Roestenburg | Code</title><description>Software Architecture, Software Craftsmanship and Polyglot programming</description><link>http://roestenburg.agilesquad.com/</link><managingEditor>noreply@blogger.com (Raymond Roestenburg)</managingEditor><generator>Blogger</generator><openSearch:totalResults>21</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-7344834789587593079</guid><pubDate>Thu, 01 Sep 2011 18:25:00 +0000</pubDate><atom:updated>2011-09-01T22:32:59.674+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Akka</category><category domain="http://www.blogger.com/atom/ns#">Scala</category><title>Testing oneway actors with the stackable trait pattern</title><description>Just a quick post on something quite simple our team came up with recently for testing a particular type of Actor.&lt;br /&gt;It comes in handy when you want to test an Actor that receives one-way messages and does not send out any messages, or reply to messages. Maybe after processing you want to assert some state somewhere.&lt;br /&gt;&lt;br /&gt;Actors that respond to request/response are very easy to test. You don&#39;t have to use any Barriers or Latches or even the (very handy) TestKit, you just ask the Actor to send a reply using !!, and assert on the reply, fail on timeout.&lt;br /&gt;&lt;br /&gt;Would it not be nice to test one-way Actors in the same way? What we would like is for the Actor to just send the exact same message back that was sent to it after it is done processing the message. Of course only in a test scenario. That way you would be able to test one-way messages in the same way as request/response messages.&lt;br /&gt;&lt;br /&gt;The idea was to dynamically add some code to wrap around the Actor that you would like to test, in some way delegate to the Actor, and always do a reply to the sender with the original message, after the Actor is done with the processing of that message. That way the test becomes very easy, you just send a &#39;asking&#39; !! to the Actor, the Actor does it&#39;s normal thing as if it received a &#39;telling&#39; ! after which the extra bit of code kicks in and sends the original message back to the unit test, so you know its done its job.&lt;br /&gt;&lt;br /&gt;Akka has a nice way of handling &amp;nbsp;the difference between one-way and request/response. You can use the reply_? message from within an Actor, which replies back to the sender if the sender asked for a response, or does nothing in the event the sender &#39;told&#39; the Actor something in one-way style.&lt;br /&gt;&lt;br /&gt;The easiest way we found to dynamically add a sort of template method was to use a stackable trait (which is described on the artima site&amp;nbsp;&lt;a href=&quot;http://www.artima.com/scalazine/articles/stackable_trait_pattern.html&quot;&gt;here&lt;/a&gt;). The below ReplyAfterProcessing trait overrides the receive of the Actor, first applies the Actor&#39;s receive (which is a PartialFunction) and chains it with an anonymous partial function that always replies the message.&lt;br /&gt;&lt;br /&gt;&lt;script src=&quot;https://gist.github.com/1186802.js?file=ReplyAfterProcessing.scala&quot;&gt;&lt;/script&gt;&lt;br /&gt;That way you can test a one-way Actor like this. The &quot;with ReplyAfterProcessing&quot; mixes in the trait and replaces the standard receive processing &quot;dynamically&quot;.&lt;br /&gt;&lt;script src=&quot;https://gist.github.com/1186825.js?file=testReplyAfterProcessing.scala&quot;&gt;&lt;/script&gt; &lt;br /&gt;Happy hAkking!&lt;br /&gt;</description><link>http://roestenburg.agilesquad.com/2011/09/testing-oneway-actors-with-stackable.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-3287660964122333525</guid><pubDate>Fri, 11 Feb 2011 23:13:00 +0000</pubDate><atom:updated>2011-02-12T00:13:30.830+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Akka</category><category domain="http://www.blogger.com/atom/ns#">Scala</category><title>Unit testing Akka Actors with the TestKit</title><description>Just a quick post to show some examples of how you can use the akka.util.TestKit to unit test Actors. I&#39;m not sure when it was added to Akka but it is really handy. Instead of using CyclicBarriers and CountDownLatches, you just mixin this very handy trait into your spec, akka.util.TestKit.&lt;br /&gt;&lt;br /&gt;I added some examples of test scenarios that pop up frequently when working with Actors:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;You send something to an Actor and you would like to know if it received the message&lt;/li&gt;&lt;li&gt;You send something to an Actor and that in turn does some processing and on success sends something to another Actor and you would like to know if that Actor received a specific message&lt;/li&gt;&lt;li&gt;You send some messages and you are not interested in every message the Actor receives and would like to ignore them until some message is received&lt;/li&gt;&lt;li&gt;You would like to know for sure that an Actor does not send through certain messages to others&lt;/li&gt;&lt;li&gt;You would like to know what an Actor sends back as a response based on a certain message&lt;/li&gt;&lt;/ul&gt;Testing this by hand with the correct concurrent latches and barriers can be brittle and quite error prone, not to mention quite complex.&lt;br /&gt;&lt;br /&gt;So how does it work? The TestKit sort of swaps out the senderOption of an Actor through an implicit value scoping trick, which means that when your Actor sends back a message (to &quot;the sender&quot;, for instance with a reply), it automatically sends it back to a testActor in TestKit, which queues up messages for you so you can inspect stuff. You can also use that same testActor when you have an Actor that sends messages to some ActorRef. You just switch out the ActorRef you would normally pass to your Actor with the testActor Ref.&lt;br /&gt;&lt;br /&gt;I added some very simple Actors for the above scenarios, which touch a lot of typical interactions:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;EchoActor - an Actor that just echoes any message you send to it&lt;/li&gt;&lt;li&gt;ForwardingActor - an Actor that forwards a message to another Actor(Ref)&lt;/li&gt;&lt;li&gt;FilteringActor - an Actor that forwards only certain messages (of type String)&lt;/li&gt;&lt;li&gt;SequencingActor - an Actor that forwards some random amount of uninteresting messages, an interesting message, and then some random amount of uninteresting messages&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;As you can see in the code below, you use a within block to indicate that some piece of code must complete with a certain duration. Every within block gets handled sequentially to keep things simple. Some nice methods and implicits in akka.util.duration make it possible to just write &#39;within(100 millis)&#39; to indicate a duration of 100 milliseconds, or &#39;within(50 millis, 100 millis)&#39; to indicate a min and max for the duration.&lt;br /&gt;Then you just bang out some messages on an ActorRef. After that you can use expectMsg to assert that a specific message has been received, or expectNoMsg to assert that no message should have been received. &amp;nbsp;&#39;ignoreMsg&#39; takes a partial function that ignores all messages for which the partial function returns true (Funny, the scala code explains it better than that sentence just now). &amp;nbsp;in the test with the SequencingActor, I ignore all messages that are not &quot;something&quot;, than assert the &quot;something&quot; message and than ignore everything again that is not &quot;something&quot;, making sure there are no messages after that. Make sure you stop all actors after all.&lt;br /&gt;Anyway, enough rambling, check out this gist :)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;script src=&quot;https://gist.github.com/823180.js?file=gistfile1.scala&quot;&gt;&lt;/script&gt;</description><link>http://roestenburg.agilesquad.com/2011/02/unit-testing-akka-actors-with-testkit_12.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-8525471958872886094</guid><pubDate>Wed, 09 Feb 2011 22:47:00 +0000</pubDate><atom:updated>2011-02-11T15:29:29.785+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Akka</category><category domain="http://www.blogger.com/atom/ns#">Scala</category><title>Starting with Akka 1.0</title><description>Since version 1.0 of Akka is coming out very soon, I thought it might be handy to write a quick new post on getting started with Akka again since a couple of things have gotten quite a bit easier.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Development setup&lt;/b&gt;&lt;br /&gt;I am using the following tools:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://code.google.com/p/simple-build-tool/&quot;&gt;sbt&lt;/a&gt; (0.7.4)&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.jetbrains.com/idea/&quot;&gt;Intellij IDEA Community Edition&lt;/a&gt;&amp;nbsp;(10.0) with Scala plugin&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/mpeltonen/sbt-idea&quot;&gt;sbt-idea&lt;/a&gt;&amp;nbsp;(latest)&lt;/li&gt;&lt;/ul&gt;Install these tools by following the links. I am using sbt-idea as a sbt processor (see sbt-idea link).&amp;nbsp;&lt;a href=&quot;https://github.com/orfjackal/idea-sbt-plugin&quot;&gt;idea-sbt-plugin&lt;/a&gt;&amp;nbsp;is a plugin that you can use to run sbt from within IDEA.&amp;nbsp;Add the Scala plugin and idea-sbt-plugin (look for SBT) in IDEA by using the plugin manager (Settings-&amp;gt; Plugins).&lt;br /&gt;After you have installed these tools you first need to create an sbt project. So lets do that first. ($ means I&#39;m typing in the console, &amp;gt; means I&#39;m in sbt, scala&amp;gt; means I&#39;m in scala interpreter)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Minimal setup&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;$ mkdir akkastart&lt;/div&gt;$ cd akkastart&lt;br /&gt;$ sbt&lt;br /&gt;press Y to start a new project, fill in some details like name, organization, version, scala version (2.8.1), sbt version (0.7.4) and wait for sbt to download scala and sbt dependencies.&lt;br /&gt;This should create a lib, project, src and target directory. Create a project/build/ directory, add Project.scala to it with the following content:&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sbt._&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sbt_akka_bivy._&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyProject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ProjectInfo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DefaultProject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AkkaProject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Create a project/plugins directory and add a Plugins.scala to it with the following content:&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sbt._&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Plugins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ProjectInfo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PluginDefinition&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bumRepo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Bum Networks Release Repository&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://repo.bumnetworks.com/releases&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AkkaRepo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Akka Repository&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://akka.io/repository&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;akkaPlugin&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;se.scalablesolutions.akka&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;akka-sbt-plugin&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;1.0-RC6&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sbtAkkaBivy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;net.evilmonkeylabs&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;sbt-akka-bivy&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.2.0&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;The akka plugin makes getting all the dependencies and modules for akka extremely easy. The bivy plugin is just really handy for deployment.&lt;br /&gt;Then run sbt update. this will add a lib_managed directory with the minimal dependencies for Akka. add akka modules to the Project.scala file if you expect to use them, for instance akka-camel:&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sbt._&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sbt_akka_bivy._&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyProject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ProjectInfo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DefaultProject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AkkaProject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;akkaCamel&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;akkaModule&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;camel&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;run sbt update after adding akka modules.&lt;br /&gt;Now we can generate an idea project from the sbt project by running sbt idea: (if you followed installation instructions for sbt-idea as processor from the sbt-idea page)&lt;br /&gt;&lt;br /&gt;$ sbt idea&lt;br /&gt;&lt;br /&gt;That creates a .iml file your directory and a .idea directory with all the stuff Idea needs. (it also creates a .iml for building the sbt sources like Project.scala)&lt;br /&gt;&lt;br /&gt;Now open the .iml file with Idea. Everything should just work (Don&#39;t you just love it when that happens? :)&lt;br /&gt;Making your module (Build-&amp;gt;Make Module akkastart) builds in the same target directories as sbt would.&lt;br /&gt;Add an akka.conf to src/main/resources (so it gets on your classpath) if you don&#39;t like the defaults, check &lt;a href=&quot;http://doc.akka.io/configuration&quot;&gt;here&lt;/a&gt;&amp;nbsp;on akka.io for more information. At first you probably don&#39;t need an akka.conf yet, when Akka finds no config it sets up defaults.&lt;br /&gt;&lt;br /&gt;That&#39;s all there is to it, now you can start adding your Actors in src/main/scala as you see fit.&lt;br /&gt;Of course you can also just do something like this to get that quick scala console fix (output in italics):&lt;br /&gt;&lt;br /&gt;$ sbt&lt;br /&gt;&amp;gt; console&lt;br /&gt;&lt;br /&gt;scala&amp;gt; import akka.actor.Actor &lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;import akka.actor.Actor&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;scala&amp;gt; class PrintActor extends Actor {&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; | &amp;nbsp;def receive = {&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; | &amp;nbsp; case s:String =&amp;gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; println(&quot;received:&quot;+s)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; | &amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; | &amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; | }&lt;br /&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;defined class PrintActor&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;div&gt;scala&amp;gt; val actorRef = Actor.actorOf(new PrintActor)&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;23:28:45.830 [run-main] WARN &amp;nbsp;akka.config.Config$ -&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Can&#39;t load &#39;akka.conf&#39;.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;One of the three ways of locating the &#39;akka.conf&#39; file needs to be defined:&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1. Define the &#39;-Dakka.config=...&#39; system property option.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;2. Put the &#39;akka.conf&#39; file on the classpath.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;3. Define &#39;AKKA_HOME&#39; environment variable pointing to the root of the Akka distribution.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;I have no way of finding the &#39;akka.conf&#39; configuration file.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;Using default values everywhere.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;actorRef: akka.actor.ActorRef = Actor[PrintActor:f55f3eb0-349b-11e0-ae19-0019d2b39ec9]&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;scala&amp;gt; actorRef.start &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;23:28:59.710 [run-main] DEBUG a.d.Dispatchers$globalExecutorBasedEventDrivenDispatcher$ - Starting up Dispatchers$globalExecutorBasedEventDrivenDispatcher$[akka:event-driven:dispatcher:global]&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;with throughput [5]&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;res1: akka.actor.ActorRef = Actor[PrintActor:f55f3eb0-349b-11e0-ae19-0019d2b39ec9]&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;scala&amp;gt; actorRef ! &quot;test&quot;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;23:29:03.412 [run-main] INFO &amp;nbsp;a.d.LazyExecutorServiceWrapper - Lazily initializing ExecutorService for&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;scala&amp;gt; 23:29:03.428 [akka:event-driven:dispatcher:global-1] DEBUG akka.dispatch.MonitorableThread - Created thread akka:event-driven:dispatcher:global-1&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;received:test&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For some more examples you can check these &lt;a href=&quot;https://github.com/RayRoestenburg/AkkaExamples&quot;&gt;here on github&lt;/a&gt;, I&#39;ve updated them to 1.0-RC6.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Happy hAkking!</description><link>http://roestenburg.agilesquad.com/2011/02/starting-with-akka-10.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-1916174130228074206</guid><pubDate>Mon, 27 Sep 2010 18:59:00 +0000</pubDate><atom:updated>2010-11-29T17:19:52.387+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Akka</category><category domain="http://www.blogger.com/atom/ns#">Scala</category><title>Repeater and Idempotent Receiver implementation in Akka</title><description>&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Update to this post:&amp;nbsp;&lt;/b&gt;I have upgraded the examples to Akka 1.0-RC1. Check the updated code at github&amp;nbsp;&lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;After a couple of examples to get started with Akka, I thought it would be nice to show a more involved example.&lt;br /&gt;In this post I am going to show how you can build your own simple reliable messaging (&lt;a href=&quot;http://www.eaipatterns.com/GuaranteedMessaging.html&quot;&gt;Guaranteed Delivery&lt;/a&gt;)&amp;nbsp;on top of Akka Remote Actors. It is an implementation of an &lt;a href=&quot;http://www.eaipatterns.com/IdempotentReceiver.html&quot;&gt;Idempotent Receiver&lt;/a&gt;&amp;nbsp;and a Repeater. I&#39;m currently using the master branch of Akka (1.0-SNAPSHOT). I have put this example up&amp;nbsp;&lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples&quot;&gt;on github here&lt;/a&gt;&amp;nbsp;along with my other Akka examples from previous posts, so you can skip the lengthy explanation below completely and go straight to the source and check out the &lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/tree/master/src/main/scala/eip/idempotent/&quot;&gt;eip.idempotent&lt;/a&gt; package :)&lt;br /&gt;Instead of pygmentizing all my code into this post, I&#39;ll just link to github instead.&lt;br /&gt;&lt;br /&gt;Update: You might ask yourself why I am implementing this so high in the stack (which some very smart people did :) At the moment I need this to work on an unmodified version of Akka and I needed it quick. Building it in for instance TCP would have probably made it necessary to modify the Akka source itself and how it builds on top of JBoss Netty. I&#39;m leaving that for another day, stay tuned :)&lt;br /&gt;&lt;br /&gt;And I thought it would be nice to show the use of the LifeCycleEvent features of Akka, how it inherits all the Netty goodness and how it is a bit easier to work with Actors instead of hand-rolled threading.&lt;br /&gt;&lt;br /&gt;Anyway, back to the example.&lt;br /&gt;&lt;br /&gt;What I wanted to achieve with the code:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Recovery from error conditions on the client or the server side.&lt;/li&gt;&lt;li&gt;Guaranteed delivery of messages, even if connection loss occurs (reconnects, errors, shutdown/startup).&lt;/li&gt;&lt;li&gt;A simple lightweight protocol.&amp;nbsp;&lt;/li&gt;&lt;li&gt;It should work with Google Protobuf serialization, since I need a very compact wire protocol.&amp;nbsp;(It shouldn&#39;t be to hard to add others)&lt;/li&gt;&lt;li&gt;It should be a drop-in solution and stay out of my way. I should just be able to bang (!) on an ActorRef on the client side, and receive on an Actor on the server side.&lt;/li&gt;&lt;li&gt;I don&#39;t need the order of messages maintained.&lt;/li&gt;&lt;li&gt;It only has to work for one way messaging (for now), not for synchronous request-response. (It shouldn&#39;t be too hard to add).&lt;/li&gt;&lt;li&gt;It should work on top of Akka&#39;s Remote Actors.&amp;nbsp;&lt;/li&gt;&lt;li&gt;It should work in a network balanced infrastructure.&lt;/li&gt;&lt;li&gt;The goal is to improve the reliability of a very lean protocol, not to implement a full featured message queuing protocol or to compete with existing protocols (Because there are plenty of options already available). Keepin it simple.&lt;/li&gt;&lt;li&gt;Show that Akka takes away a lot of the complexities in building this type of stuff.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;b&gt;Idempotent Receiver&lt;/b&gt;&lt;/div&gt;An&amp;nbsp;&lt;a href=&quot;http://www.eaipatterns.com/IdempotentReceiver.html&quot;&gt;Idempotent Receiver&lt;/a&gt;&amp;nbsp;is an Enterprise Integration Pattern that is used to safely receive duplicate messages.&amp;nbsp;The main reason for the use of this pattern is for solving common problems in communicating over a network:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Network components between servers might duplicate messages&lt;/li&gt;&lt;li&gt;Connection errors might only be known on one side of the communication link&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/_8SomWRym6Jg/TIPI8GpBdRI/AAAAAAAAAaA/Q6IFgdA-1Pg/s1600/dupmsg.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/_8SomWRym6Jg/TIPI8GpBdRI/AAAAAAAAAaA/Q6IFgdA-1Pg/s320/dupmsg.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;For instance, a client sends a message, receives no error on the connection and assumes the message is received by the server. Some network component between the client and the server routes the message to the server, where a connection error occurs. The client is unaware of this and the server never receives the message.&lt;br /&gt;Even in the case where the client uses request-response to communicate with the server, the client cannot be sure that the request has been handled or not, when the client does not receive a reply. The server might have handled the request and failed to send back a response. Resending a message to the server on no reply could result in the operation being applied twice.&lt;br /&gt;&lt;br /&gt;The Idempotent Receiver pattern allows the client to repeat messages, because it can identify duplicate messages.&amp;nbsp;I&#39;ve implemented the Idempotent Receiver as a Remote Actor. It passes messages on to the actual Actor that is supposed to receive the messages, unless the message is a duplicate of course. The Idempotent Receiver checks every incoming message on an &lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/blob/master/src/main/scala/eip/idempotent/Envelopes.scala&quot;&gt;Envelopes implementation&lt;/a&gt;. I&#39;ve just included some in-memory &amp;nbsp;implementations, it is quite easy to add a persistent one, for instance using the Akka Persistence module.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Repeater&lt;/b&gt;&lt;br /&gt;On the client side I&#39;ve implemented an Actor that communicates with the Idempotent Receiver on the server side. The Repeater keeps track of all messages that are sent to the server in a &lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/blob/master/src/main/scala/eip/idempotent/Repeater.scala&quot;&gt;RepeatBuffer&lt;/a&gt; and keeps a copy of the messages, which it can repeat if needed to the server. The user of the repeater can just get an ActorRef to it and send the messages as you normally would. The Repeater wraps every message in an Envelope, and sends this Envelope to the Idempotent Receiver using the Remote Actor Protocol.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Protocol&lt;/b&gt;&lt;br /&gt;I&#39;ve cheated a bit (in Dutch we say &quot;Beter goed gestolen dan slecht bedacht&quot; :) and looked at how the Remote Actor Protocol works, and borrowed a bit from TCP and other message standards and came up with the following.&lt;br /&gt;Every message will be sent inside an Envelope. An Envelope consists of a Frame ID and an &amp;nbsp;Envelope ID, and a Payload part that can contain any message.&amp;nbsp;I&#39;ve created protobuf message definition for this &lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/blob/master/src/main/proto/IdempotentProtocol.proto&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;Because the Repeater and Idempotent Receiver are keeping messages in memory or on disk, you need a way to tell which messages can be removed. That is where the Frame comes in.&amp;nbsp;Envelopes are always part of a Frame, which is like a &#39;sticky session&#39; for a number of Envelopes. The Frame consists of a source address, a destination address, an ID and a size (the amount of envelopes).&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/_8SomWRym6Jg/TKDj9KUFODI/AAAAAAAAAaM/Mpbwvf-GOY0/s1600/idempotent.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;512&quot; src=&quot;http://1.bp.blogspot.com/_8SomWRym6Jg/TKDj9KUFODI/AAAAAAAAAaM/Mpbwvf-GOY0/s640/idempotent.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The Repeater first requests a Frame from the Idempotent Receiver and then starts sending messages for that Frame. The Idempotent Receiver checks if it has received every (unique) message for a Frame based on the Frame size. When a Frame is complete, the Idempotent Receiver sends a CompleteFrameRequest out of band to the Repeater and removes the envelopes from storage. The Repeater receives the request and also removes the envelopes from storage.&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;As from Akka 0.10 you can register Lifecycle event listeners on both the RemoteClient&amp;nbsp;and&amp;nbsp;RemoteServer (By the way, check out the awesome&amp;nbsp;&lt;a href=&quot;http://groups.google.com/group/akka-user&quot;&gt;Akka User List&lt;/a&gt;, the guys there are extremely helpful).&lt;/div&gt;&lt;br /&gt;I use the Lifecycle event Listeners to be notified of connection errors and successful reconnects.When the connection has been restored after a disconnect or error, a repeat of the Frame is triggered on the client side, or a repeat request of the Frame is triggered on the server side to the Repeater with some selective acknowledgement of the already received Envelope IDs.&lt;br /&gt;&lt;br /&gt;Since the Envelope message is just another protobuf encoded message, Akka handles it as usual in the RemoteClient and RemoteServer using the Akka Remote Protocol. The Idempotent Receiver receives the Envelope message and deserializes the payload to the correct protobuf message that the Actor is expecting, and the Envelope itself. Right now it only works for protobuf messages because that&#39;s all I use, but the&amp;nbsp;&lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/blob/master/src/main/scala/eip/idempotent/EnvelopeSerializer.scala&quot;&gt;EnvelopeSerializer&lt;/a&gt;&amp;nbsp;can be easily changed to handle all types of messages (If that code looks familiar it&#39;s because it&#39;s basically a copy of the MessageSerializer class in Akka :)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Scale out&lt;/b&gt;&lt;br /&gt;A problem with the Idempotent Receiver is that it is not easy to scale out. If you would have RemoteActors distributed over many Servers and use a network load balancer, you can&#39;t just put an Idempotent Receiver on all of the servers, since they would not know about each other. Sharing state over distributed nodes is not really what you want, it gets complicated very quickly. Instead of distributing the Envelope and Frame state over several servers, I have implemented a&amp;nbsp;&lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/blob/master/src/main/scala/eip/idempotent/Envelopes.scala&quot;&gt;JGroups based Envelopes implementation&lt;/a&gt;&amp;nbsp;where every node in the cluster &#39;owns&#39; the Frames that is has created. If it receives a message for a Frame that it doesn&#39;t own, it sends it into the cluster, so that the Idempotent Receiver that owns the Frame can handle it. You can specify a range for the Frame IDs in the &lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/blob/master/src/main/scala/eip/idempotent/Envelopes.scala&quot;&gt;Envelopes&lt;/a&gt; so that different servers will never create the same Frame.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Testing&lt;/b&gt;&lt;br /&gt;You can check out the unit tests &lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/tree/master/src/test/scala/unit/eip/idempotent&quot;&gt;here&lt;/a&gt;. To make sure that everything works, I have written a very simple and crude &lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/blob/master/src/test/scala/tools/NetworkProxy.scala&quot;&gt;Network Proxy (Blocking I/O) for testing&lt;/a&gt;, that will be used in the unit tests between the Repeater and Idempotent Receiver. The Network Proxy can be started, stopped, and connection errors can be caused by registering a function in the loop that receives from the client and passes this to the RemoteServer, and in the loop that receives responses from the RemoteServer and passes these back to the client.&lt;br /&gt;&lt;br /&gt;In the repository you can also find&amp;nbsp;&lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/blob/master/src/test/scala/unit/eip/idempotent/ConnectionErrorSpecs.scala&quot;&gt;this unit test&lt;/a&gt; that tests if all LifeCycle events (both RemoteClient and RemoteServer) are triggered by the Akka framework, using this simple proxy.&lt;br /&gt;&lt;br /&gt;I&#39;ve written &lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/blob/master/src/test/scala/unit/eip/idempotent/RepeaterAndReceiverSpecs.scala&quot;&gt;this unit test here&lt;/a&gt; to test the Repeater and Idempotent Receiver. The JGroups version is tested&amp;nbsp;&lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples/blob/master/src/test/scala/unit/eip/idempotent/ScaledReceiverSpecs.scala&quot;&gt;in this unit test here&lt;/a&gt;.&amp;nbsp;Let me know what you think!&lt;br /&gt;&lt;div style=&quot;margin: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://roestenburg.agilesquad.com/2010/09/repeater-and-idempotent-receiver.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_8SomWRym6Jg/TIPI8GpBdRI/AAAAAAAAAaA/Q6IFgdA-1Pg/s72-c/dupmsg.png" height="72" width="72"/><thr:total>7</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-6813108363263986371</guid><pubDate>Tue, 27 Jul 2010 06:23:00 +0000</pubDate><atom:updated>2010-11-29T17:14:06.209+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Akka</category><category domain="http://www.blogger.com/atom/ns#">Scala</category><title>Upgrading examples to Akka master (0.10) and Scala 2.8.0 Final</title><description>&lt;b&gt;Update on this post: &lt;/b&gt;I have upgraded the AkkaExampels git repo to version 1.0-RC1. Camel references are upgraded to 2.5.0. I have also included a reference to the scalablesolutions Akka maven repository, so that the akka-sbt-plugin is automatically downloaded at sbt update. &lt;a href=&quot;https://github.com/RayRoestenburg/AkkaExamples&quot;&gt;AkkaExamples on github&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In this post I am going to write about upgrading from Akka 0.8.1 to Akka 0.10. (at the moment 0.10 is not ready yet, but for simplicity I will refer to 0.10, To be exact it&#39;s git commit&amp;nbsp;c737e2edf4b9ad980d6922f169ca4fb19f8c8284 :)&lt;br /&gt;Also to make things a bit simpler, I have pushed my previous Akka examples here to&amp;nbsp;&lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples&quot;&gt;github&lt;/a&gt;, so you can just clone from there and check it out. (You will need to build Akka as shown below first until 0.10 comes out, and be sure to run &#39;sbt update&#39; &amp;nbsp;before you try to build)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Building Akka&lt;/b&gt;&lt;br /&gt;At the time of writing there is no 0.10 release yet that you can just download, so I built Akka from master and published it to my local ivy repository. the sbt build has really improved a lot, the update is quicker and so is the build:&lt;br /&gt;&lt;br /&gt;$ git clone git://github.com/jboner/akka.git&lt;br /&gt;$ cd akka&lt;br /&gt;$ sbt update&lt;br /&gt;$ sbt dist&lt;br /&gt;$ sbt publish-local&lt;br /&gt;$ cd akka-sbt-plugin&lt;br /&gt;$ sbt publish-local&lt;br /&gt;&lt;br /&gt;I am also building and publishing the akka-sbt-plugin to local, so I can use it later.&lt;br /&gt;Akka now uses Google Protobuf 2.3.0. If you are going to use Google Protobuf for your own messages, you will need to install the 2.3.0 protoc compiler, get it &lt;a href=&quot;http://code.google.com/p/protobuf/downloads/detail?name=protobuf-2.3.0.tar.gz&amp;amp;can=2&amp;amp;q=&quot;&gt;here&lt;/a&gt;&amp;nbsp;and follow instructions in the readme file.&lt;br /&gt;In case you are going to use Apache Camel, you need to upgrade the Camel dependencies to 2.4.0 (Akka 0.8.1 used Camel 2.2.0).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SBT Project file plugins&lt;/b&gt;&lt;br /&gt;Akka 0.10 comes with a very nice addition for SBT, the AkkaProject sbt plugin. This makes it a lot more succinct and easy to start off with an Akka project, as you can see below:&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sbt._&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Process._&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sbt_akka_bivy._&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ProjectInfo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DefaultProject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AkkaProject&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AkkaKernelDeployment&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;akkaCamel&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;akkaModule&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;camel&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;akkaKernel&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;akkaModule&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;kernel&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;junit&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;junit&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;junit&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;4.8.1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test-&amp;gt;default&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;camelFtp&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;org.apache.camel&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;camel-ftp&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;2.4.0&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;camelMina&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;org.apache.camel&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;camel-mina&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;2.4.0&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;camelJetty&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;org.apache.camel&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;camel-jetty&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;2.4.0&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;scalatest&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;org.scalatest&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;scalatest&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;1.2-for-scala-2.8.0.final-SNAPSHOT&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test-&amp;gt;default&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;repositories&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;scala-tools-snapshots&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;br /&gt;      &lt;span class=&quot;s&quot;&gt;&quot;http://scala-tools.org/repo-snapshots/&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;As you can see I have added some Camel components to play with, and I&#39;ve added the scalatest and junit dependencies for unit testing. The Project file now uses the AkkaProject plugin and the Bivy Sack plugin (sbt-akka-bivy) for microkernel deployments (check &lt;a href=&quot;http://github.com/bwmcadams/sbt-akka-bivy&quot;&gt;here&lt;/a&gt;, really cool) which I am going to use in a later post for quick and easy deployment when I actually have something to deploy, the project only contains unit tests for now. Before you can use this Project file, you need to add a Plugins.scala file to the project/plugins directory, which describes the akka-sbt-plugin that we built, and it also pulls in the sbt-akka-bivy plugin for deployment:&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sbt._&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Plugins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ProjectInfo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PluginDefinition&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bumRepo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Bum Networks Release Repository&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://repo.bumnetworks.com/releases&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;akkaPlugin&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;se.scalablesolutions.akka&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;akka-sbt-plugin&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.10&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sbtAkkaBivy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;net.evilmonkeylabs&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;sbt-akka-bivy&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.2.0&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Run &#39;sbt update&#39; to pull the dependencies in. After that you can setup a new project in IDEA. (I&#39;m hoping an sbt IDEA plugin will get really good soon cause this always means some fiddling with the classpath).&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Intellij IDEA&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;I am using the Intellij IDEA Community EAP (95.390 to be precise) which you can get from&amp;nbsp;&lt;a href=&quot;http://confluence.jetbrains.net/display/IDEADEV/Maia+EAP&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Once you have installed it, update the Scala plugin in the plugins section if you had a previous version, otherwise install from the available list. (File-Settings-Plugins)&lt;/div&gt;&lt;br /&gt;Choose a new project, from existing source, make sure you select the compile and test jars (in lib_managed) and the scala 2.8.0 jars, leave out the 2.7.7 ones from sbt. You can add a Scala Facet yourself, or IDEA will autodetect it and you can choose that it will create it for you, just make sure to use the 2.8.0 final ones. The same goes for the src &#39;IDEA module&#39;, you can add it in the new project wizard or in the Project Structure settings (set the src/main/scala as source and src/test/scala as test). Make sure you set IDEA to use the 2.8.0 final compiler and library in the Scala Facet settings, to the jars found in project/boot/scala-2.8.0/lib. Put the scala 2.8.0 jars right after your JDK in your module dependencies.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/_8SomWRym6Jg/TEwGid_oy0I/AAAAAAAAAZg/zdotMakDK04/s1600/project-structure-deps.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;http://4.bp.blogspot.com/_8SomWRym6Jg/TEwGid_oy0I/AAAAAAAAAZg/zdotMakDK04/s640/project-structure-deps.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Project Structure - src module dependencies&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/_8SomWRym6Jg/TEwGnpADBMI/AAAAAAAAAZo/_F24bGBZxaw/s1600/project-structure-sources.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;http://4.bp.blogspot.com/_8SomWRym6Jg/TEwGnpADBMI/AAAAAAAAAZo/_F24bGBZxaw/s640/project-structure-sources.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Project Structure - src module sources&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/_8SomWRym6Jg/TEwGs35TbeI/AAAAAAAAAZw/hxh3cQXsUQo/s1600/project-structure-scala2.8.0.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;http://1.bp.blogspot.com/_8SomWRym6Jg/TEwGs35TbeI/AAAAAAAAAZw/hxh3cQXsUQo/s640/project-structure-scala2.8.0.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Project Structure - scala 2.8.0 project library&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;I have updated the examples from previous posts about Akka in the project on github. The biggest difference from Akka 0.8 is that the identity and the instance of an Actor are separated respectively into an ActorRef trait and an Actor trait, as described &lt;a href=&quot;http://doc.akkasource.org/migration-guide-0.8.x-0.9.x&quot;&gt;here&lt;/a&gt;. There is an Actor object as well which is used as a factory module. The Actor.actorOf method makes sure that you cannot access the Actor instance methods directly to prevent threading problems if you would do such a thing. In the examples I import all the Actor object methods. You can only send messages to the Actor implementation through the API exposed through the ActorRef class. Within the Actor instance, this is done through the self reference.&lt;br /&gt;&lt;br /&gt;Below the updated code for 0.10 of the&amp;nbsp;&lt;a href=&quot;http://roestenburg.agilesquad.com/2010/05/starting-with-akka-part-2-intellij-idea.html&quot;&gt;previous simple example&lt;/a&gt;&amp;nbsp;in 0.8, to show the usage of actorOf in the specs and the self reference in the Worker Actor.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.Spec&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.matchers.MustMatchers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.actor.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.actor.Actor._&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * A Spec for an example Worker Actor.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;WorkerSpecs&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Spec&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MustMatchers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;A Worker&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;(when it queues commands)&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;should have the correct number of commands queued&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actorOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;CountResponse&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountCommandsQueued&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getOrElse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asInstanceOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;CountResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountCommandsQueued&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getOrElse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asInstanceOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;CountResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;(when it executes all queued commands)&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;should have no commands queued after executing&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actorOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;CountResponse&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountCommandsQueued&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getOrElse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asInstanceOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;CountResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Execute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountCommandsQueued&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getOrElse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asInstanceOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;CountResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actorRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**A command message */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/** A message to get the amount of commands queued*/&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountCommandsQueued&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/** A message to execute all commands queued */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Execute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/** A message reply on the CountCommandsQueued message */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * A Worker actor that receives Commands, queues the commands, and executes commands on the Execute message,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * as example for some simple Actor testing&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Nil&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receive&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Command&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Execute&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dropRight&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;CountCommandsQueued&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Self reference&lt;/b&gt;&lt;br /&gt;In the simple example above I updated the code that uses the Actor API from within the Actor, by prefixing the calls with self. What you can also do is import the &#39;self methods&#39; in the Actor class, in case you want to save time typing &#39;self&#39; all the time. I&#39;ve done this in the 0.10 update to my&amp;nbsp;&lt;a href=&quot;http://roestenburg.agilesquad.com/2010/05/join-messages-with-akka.html&quot;&gt;previous example to join messages&lt;/a&gt;&amp;nbsp;in 0.8 (FirstMessageHandler Actor):&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.matchers.MustMatchers&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.Spec&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.actor.Actor._&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.actor.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ActorRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ActorRegistry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * A Spec for the Aggregator&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AggregatorSpecs&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Spec&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MustMatchers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;aggregateMessageReceived&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;aggregateMessage&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;AggregateMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;An Aggregator&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;(when it receives FirstMessage and then SecondMessage)&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;firstRef&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actorOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstMessageHandler&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;secondRef&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actorOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SecondMessageHandler&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receiveTestRef&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;AggregateMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;n&quot;&gt;aggregateMessageReceived&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;n&quot;&gt;aggregateMessage&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;aggregator&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actorOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Aggregator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;receiveTestRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;firstRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;secondRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;aggregator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;should send an AggregateMessage containing data of FirstMessage and SecondMessage to the passed in actor&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;firstRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;id-1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;name-1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;secondRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SecondMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;data-1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;aggregateMessageReceived&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;aggregateMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;id-1&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;aggregateMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;name-1&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;aggregateMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;data-1&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;firstRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;secondRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;aggregator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/** A message that is expected to arrive first*/&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/** A message that is expected to arrive second*/&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SecondMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/** An aggregated message, from first and second */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AggregateMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/** A command to get the last message*/&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GiveMeLastMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * An Aggregator actor that aggregates a first and second message type&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Aggregator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pass&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ActorRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receive&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;SecondMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Aggregator, my data is &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;firstMessageHandler&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ActorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ActorRegistry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actorsFor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;classOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;FirstMessageHandler&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Any&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;firstMessageHandler&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GiveMeLastMessage&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isDefined&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;FirstMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asInstanceOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;FirstMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Aggregator, my first message is &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ag&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AggregateMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;pass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ag&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * A Message Handler for the SecondMessage type&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SecondMessageHandler&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receive&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;SecondMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;// do some processing&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Secondmessage, my data is &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;// then call the aggregator&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;aggregator&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ActorRef&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ActorRegistry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actorsFor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;classOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Aggregator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;aggregator&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * A Message Handler for the FirstMessage type&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstMessageHandler&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;self._&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lastMessage&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;FirstMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lastRequestor&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Any&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receive&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;FirstMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;// do some processing&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Firstmessage, my name is &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;lastMessage&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lastRequestor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lastRequestor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asInstanceOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;ActorRef&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;lastMessage&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;GiveMeLastMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lastMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isDefined&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;lastRequestor&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;senderFuture&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lastMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Protobuf Serialization&lt;/b&gt;&lt;br /&gt;The Serializable.Protobuf trait has been removed in 0.10, and Akka 0.10 now uses protobuf 2.3.0. Below the updated code for 0.10 for the &lt;a href=&quot;http://roestenburg.agilesquad.com/2010/05/testing-akka-remote-actor-using.html&quot;&gt;previous simple protobuf serialization example&lt;/a&gt;&amp;nbsp;in 0.8:&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;unit.akka&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.actor.Actor&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.actor.Actor._&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;BeforeAndAfterAll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Spec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.junit.runner.RunWith&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.junit.JUnitRunner&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.remote.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoteClient&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RemoteServer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.matchers.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MustMatchers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ShouldMatchers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;unit.test.proto.Commands&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.google.protobuf.Message&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;unit.test.proto.Commands.WorkerCommand&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;unit.akka.CommandBuilder._&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * Test to check if communicating with protobuf serialized messages works.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;nd&quot;&gt;@RunWith&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;classOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;JUnitRunner&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ProtobufSpecs&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Spec&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;BeforeAndAfterAll&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MustMatchers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;RemoteServer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RemoteServer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;beforeAll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;configMap&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;, &lt;span class=&quot;kt&quot;&gt;Any&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;127.0.0.1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8091&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;afterAll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;configMap&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;, &lt;span class=&quot;kt&quot;&gt;Any&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nc&quot;&gt;RemoteClient&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shutdownAll&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shutdown&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Send using Protobuf protocol&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;should receive local protobuf pojo and reply&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;// send a local msg, check if everything is ok&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actorOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TestProtobufWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;my-name-1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;my-data-1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Any&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Commands.WorkerCommand&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;c1&quot;&gt;// test actor changes name to uppercase&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getName&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;MY-NAME-1&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;no response&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;should receive remote protobuf pojo and reply&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;//start a remote server&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actorOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TestProtobufWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;//register the actor that can be remotely accessed&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;protobuftest&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;my-name-2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;my-data-2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Any&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RemoteClient&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actorFor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;protobuftest&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;127.0.0.1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8091&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Commands.WorkerCommand&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;c1&quot;&gt;// test actor changes name to uppercase&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getName&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;MY-NAME-2&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;no response&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * Actor that sends back the message uppercased.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TestProtobufWorker&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receive&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Commands.WorkerCommand&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;received protobuf command pojo:&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;sending back a renamed pojo:&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * Shortcuts for creating WorkerCommands&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CommandBuilder&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;WorkerCommand&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nc&quot;&gt;Commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;WorkerCommand&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;newBuilder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setData&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;build&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;WorkerCommand&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;WorkerCommand&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nc&quot;&gt;Commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;WorkerCommand&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;newBuilder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setData&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;build&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;You now just work directly with the protobuf messages, instead of creating a case class that extends the Serializable.Protobuf trait and that serializes to and from the protobuf message. In the test I added the CommandBuilder object just for convenience.&lt;br /&gt;&lt;br /&gt;If you want to check out the source code go to my github repo&amp;nbsp;&lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples&quot;&gt;here&lt;/a&gt;.</description><link>http://roestenburg.agilesquad.com/2010/07/upgrading-to-akka-master-010-and-scala.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_8SomWRym6Jg/TEwGid_oy0I/AAAAAAAAAZg/zdotMakDK04/s72-c/project-structure-deps.png" height="72" width="72"/><thr:total>5</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-4765428066768430718</guid><pubDate>Wed, 23 Jun 2010 15:09:00 +0000</pubDate><atom:updated>2010-07-25T11:48:04.976+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Akka</category><category domain="http://www.blogger.com/atom/ns#">Scala</category><title>Scala 2.8.0, Akka 0.8.1 and cassandra 0.6.2</title><description>In this post I&#39;m going to install cassandra 0.6.2 on ubuntu karmic koala. I&#39;m going to use the akka persistence module to access it and write a unit test to check if everything is working. &lt;br /&gt;&lt;br /&gt;I&#39;ve used the installation instructions for cassandra as shown&amp;nbsp;&lt;a href=&quot;http://dustyreagan.com/installing-cassandra-on-ubuntu-linux/&quot;&gt;here&lt;/a&gt;, with the following changes:&lt;br /&gt;&lt;br /&gt;3. Add the following lines in /etc/apt/sources.list instead:&lt;br /&gt;&lt;br /&gt;deb http://www.apache.org/dist/cassandra/debian unstable main&lt;br /&gt;deb-src http://www.apache.org/dist/cassandra/debian unstable main&lt;br /&gt;&lt;br /&gt;That&#39;s pointing to version 0.6.2 at the moment.&lt;br /&gt;&lt;br /&gt;9. Instead change the JMX port in /etc/init.d/cassandra, it doesn&#39;t look like cassandra.in.sh is used. When I changed it in&amp;nbsp;cassandra.in.sh, Cassandra kept bumping into my local Tomcat server.&lt;br /&gt;The storage-conf.xml is in /etc/cassandra. The storage-conf.xml file that comes with akka does not seem to work and needs a small change, I have copied the below KeySpace definition in the /ect/cassandra/storage-conf.xml file:&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Keyspace&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;akka&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;KeysCachedFraction&amp;gt;&lt;/span&gt;0.01&lt;span class=&quot;nt&quot;&gt;&amp;lt;/KeysCachedFraction&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nt&quot;&gt;&amp;lt;ColumnFamily&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;CompareWith=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;UTF8Type&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;map&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nt&quot;&gt;&amp;lt;ColumnFamily&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;CompareWith=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;UTF8Type&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;vector&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nt&quot;&gt;&amp;lt;ColumnFamily&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;CompareWith=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;UTF8Type&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ref&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;ReplicaPlacementStrategy&amp;gt;&lt;/span&gt;org.apache.cassandra.locator.RackUnawareStrategy&lt;span class=&quot;nt&quot;&gt;&amp;lt;/ReplicaPlacementStrategy&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Number of replicas of the data --&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;ReplicationFactor&amp;gt;&lt;/span&gt;1&lt;span class=&quot;nt&quot;&gt;&amp;lt;/ReplicationFactor&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;c&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;c&quot;&gt;       ~ EndPointSnitch: Setting this to the class that implements&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;c&quot;&gt;       ~ AbstractEndpointSnitch, which lets Cassandra know enough&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;c&quot;&gt;       ~ about your network topology to route requests efficiently.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;c&quot;&gt;       ~ Out of the box, Cassandra provides org.apache.cassandra.locator.EndPointSnitch,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;c&quot;&gt;       ~ and PropertyFileEndPointSnitch is available in contrib/.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;c&quot;&gt;      --&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;EndPointSnitch&amp;gt;&lt;/span&gt;org.apache.cassandra.locator.EndPointSnitch&lt;span class=&quot;nt&quot;&gt;&amp;lt;/EndPointSnitch&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Keyspace&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;Cassandra complains if you don&#39;t add the ReplicaPlacementStrategy. I&#39;m not sure yet what these settings mean exactly but I didn&#39;t let that stop me :)&lt;br /&gt;&lt;br /&gt;You should now be able to start cassandra and use it from akka (sudo /init.d/etc/cassandra start). You can check if the akka keyspace is present, with the &#39;show keyspaces&#39; command &lt;a href=&quot;http://wiki.apache.org/cassandra/CassandraCli&quot;&gt;in cassandra-cli&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Be sure to check /var/log/cassandra/*.log if everything works, and you can start jconsole and connect to casssandra through JMX, check out some MBeans. (localhost, port 10036 in my case)&lt;br /&gt;&lt;br /&gt;And then a simple unit test. What is important is that you use the lazy declaration for the storage, and use the atomic blocks. You can also use the persistent map straight from an Actor, but I like to do it this way because you can switch out the implementation (for instance from Cassandra to Redis), by passing in the below PersistentMap trait to for instance an Actor constructor.&lt;br /&gt;&lt;br /&gt;You need to convert keys and values to byte arrays, so it is quite a low level interface for storing data. This unit test is very simple on purpose, I would probably use the &lt;a href=&quot;http://doc.akkasource.org/serialization&quot;&gt;Akka Serializable interfaces&lt;/a&gt; on case classes that I would want to store.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;unittest&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.stm.Transaction.Local._&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.util.Logging&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Spec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;BeforeAndAfterAll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.matchers.ShouldMatchers&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.persistence.cassandra.CassandraStorage&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.junit.JUnitRunner&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.junit.runner.RunWith&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.junit.Assert._&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.apache.cassandra.service.NotFoundException&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;nd&quot;&gt;@RunWith&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;classOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;JUnitRunner&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AkkaCassandraTest&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Spec&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ShouldMatchers&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;BeforeAndAfterAll&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Logging&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Store stuff in Cassandra using Akka persistence abstraction&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;should be able to store some stuff and find it again&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CassandraPersistentMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;test-map&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;test-key&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test-value&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;someValue&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;test-key&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;someValue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isDefined&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;someValue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;found &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;test-key not found&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anotherValue&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;no-key&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;assertFalse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;anotherValue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isDefined&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * Simple map trait  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;trait&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PersistentMap&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * Simple Map that uses Cassandra&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CassandraPersistentMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storageKey&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PersistentMap&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;c1&quot;&gt;//Using atomic we define the transaction span.&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;lazy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storage&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;atomic&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CassandraStorage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storageKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Unit&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;atomic&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;storage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getBytes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getBytes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;storage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;commit&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;atomic&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getBytes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bytes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;nc&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bytes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://roestenburg.agilesquad.com/2010/06/akka-081-and-cassandra-062.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-8480184641291048803</guid><pubDate>Thu, 27 May 2010 20:42:00 +0000</pubDate><atom:updated>2010-07-25T11:48:25.038+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Akka</category><category domain="http://www.blogger.com/atom/ns#">Scala</category><title>Testing Akka Remote Actor using Serializable.Protobuf</title><description>Just a short post to show how you can test a remote actor, where the messages are serialized using Google protobuf. Protobuf is automatically used for the internal akka protocols (to make remote actors possible for instance), but the messages that you define yourself are not automatically encoded using protobuf of course, (you would need to do quite a bit of reflection and include the protoc compiler in the framework, and some translation or mapping for that to automagically work, that&#39;s a path down the rabbit hole I&#39;m glad the akka team didn&#39;t take). &lt;br /&gt;&lt;br /&gt;By default java serialization is used. There is a setting in akka.conf for serialization, but that&#39;s only for the cluster protocol. I&#39;m using akka 0.8 by the way.&lt;br /&gt;&lt;br /&gt;Let&#39;s get back to the task at hand. &lt;br /&gt;&lt;br /&gt;First you need to install protobuf 2.2.0. (check&amp;nbsp;&lt;a href=&quot;http://code.google.com/p/protobuf/&quot;&gt;here&lt;/a&gt;). 2.3.0 gave me some issues, the generated java classes did not compile. (and akka 0.8 ships with the 2.2.0 jar, so you might be asking for trouble with 2.3.0)&lt;br /&gt;&lt;br /&gt;Create a .proto file that describes the message (in my case I named the file ProtobufCommandPojo.proto):&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;proto&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;n&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;workercommand&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;n&quot;&gt;required&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uint64&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;n&quot;&gt;required&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;n&quot;&gt;required&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Then generate the java code for the protobuf message (in my case to a java directory):&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;$ protoc ProtobufCommandPojo.proto --java_out ../../java&lt;/div&gt;&lt;br /&gt;This generates quite a few java classes, mainly&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; white-space: pre;&quot;&gt;ProtobufCommandPojo&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Create a message case class that mixes in the Serializable.Protobuf trait:&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;unit&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.serialization.Serializable&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;test.proto.ProtobufCommandPojo&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * message class that uses Serializable.Protobuf trait.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * uses generated protobuf classes.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ProtobufMixedIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Long&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Serializable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Protobuf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;ProtobufMixedIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getMessage&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;com.google.protobuf.Message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;       &lt;span class=&quot;nc&quot;&gt;ProtobufCommandPojo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;workercommand&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getDefaultInstance&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;toBuilder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setData&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;     &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;As you can see you use the generated class to do the actual protobuf message building. this is basically the mapping between protobuf and the message class.&lt;br /&gt;Note: the Serializable.Protobuf class has a default implementation for fromBytes, which assumes that you do a standard mapping between your class and the protobuf message definition:&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;def fromBytes(bytes: Array[Byte]): T = getMessage.toBuilder.mergeFrom(bytes).asInstanceOf[T]&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;I&#39;m expecting that if you build a protobuf message in a different way than is &#39;expected&#39; in the getMessage method, you might not get the result you want. I&#39;m guessing that there is some reflection or naming convention going on under the hood to make this default implementation work, I&#39;ll leave that investigation to you if you feel like you want to know how this works exactly.&lt;br /&gt;&lt;br /&gt;And then the unit test. You simply work with the case class ProtobufMixedIn, as you would with a normal message. Akka does the rest.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;syntax&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;unit&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.actor.Actor&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;BeforeAndAfterAll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Spec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.junit.runner.RunWith&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.junit.JUnitRunner&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.remote.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoteClient&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RemoteServer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.matchers.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MustMatchers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ShouldMatchers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * Test to check if communicating with protobuf serialized messages works.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;nd&quot;&gt;@RunWith&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;classOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;JUnitRunner&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ProtobufTest&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Spec&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MustMatchers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Send using Protobuf protocol&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;should receive local protobuf pojo and reply&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;// send a local msg, check if everything is ok&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TestProtobufWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ProtobufMixedIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;my-name-1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;my-data-1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;ProtobufMixedIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ProtobufMixedIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;c1&quot;&gt;// test actor changes name to uppercase&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;MY-NAME-1&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;no response&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;should receive remote protobuf pojo and reply&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;//start a remote server&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RemoteServer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TestProtobufWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;127.0.0.1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8091&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;//register the actor that can be remotely accessed&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;protobuftest&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ProtobufMixedIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;my-name-2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;my-data-2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;ProtobufMixedIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RemoteClient&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actorFor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;protobuftest&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;127.0.0.1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8091&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ProtobufMixedIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;c1&quot;&gt;// test actor changes name to uppercase&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;MY-NAME-2&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;no response&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;//shutdown server and client processes&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shutdown&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;nc&quot;&gt;RemoteClient&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shutdownAll&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; * Actor that sends back the message uppercased.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cm&quot;&gt; */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TestProtobufWorker&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receive&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ProtobufMixedIn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;received protobuf command pojo:&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ProtobufMixedIn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;sending back a renamed pojo:&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://roestenburg.agilesquad.com/2010/05/testing-akka-remote-actor-using.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>5</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-2656192471088444818</guid><pubDate>Thu, 06 May 2010 21:20:00 +0000</pubDate><atom:updated>2010-11-29T17:19:08.893+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Akka</category><category domain="http://www.blogger.com/atom/ns#">Scala</category><title>Join messages with Akka</title><description>&lt;b&gt;Update to this post:&amp;nbsp;&lt;/b&gt;I have upgraded the examples to Akka 1.0-RC1. Check the updated code at github&amp;nbsp;&lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Akka raises the abstraction level for writing concurrent systems. In this post I want to give a simple example of this.&lt;br /&gt;&lt;br /&gt;Let&#39;s say that you have two types of messages coming into your system (of let&#39;s say type FirstMessage and SecondMessage), and you would like to:&lt;br /&gt;1. First do some processing on them separately/independently and after that:&lt;br /&gt;2. &#39;join&#39; or correlate these two messages when they come in one after the other in a pair, based on the time they are received by the system and send out a new message.&lt;br /&gt;3. All processing has to be non-blocking.&lt;br /&gt;4 only make aggregates of the messages that come in as [FirstMessage, SecondMessage], ignoring consecutive FirstMessages.&lt;br /&gt;&lt;br /&gt;In this example, the only thing you know is that one type of message always comes in a little bit later than the other, and when this happens, you want to combine the information in these two messages into one outgoing message. And, this is not the only thing happening in the system, you also want to handle these messages asynchronously, do some type of processing before aggregation.&lt;br /&gt;&lt;br /&gt;Something like this (apologies for the crappy graphics, got no time to waste on it :)&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/_8SomWRym6Jg/S-MWADnM6BI/AAAAAAAAAYc/AKCYkS1IxWc/s1600/aggregator.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;212&quot; src=&quot;http://2.bp.blogspot.com/_8SomWRym6Jg/S-MWADnM6BI/AAAAAAAAAYc/AKCYkS1IxWc/s640/aggregator.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;I tried to sort of use the enterprise integration patterns diagrams. On the left side the two types of messages that come in (let&#39;s call them of type FirstMessage and SecondMessage), on the right side the result (AggregatedMessage). I was so lazy to make this diagram, that I left out the two processes that do something with FirstMessage and SecondMessage on just before t=1 and t = 2, but I guess you get the drift.&lt;br /&gt;&lt;br /&gt;Without something like Akka, I would probably dive into the java concurrent package.. (what follows is a braindump, you can add your own pinch of salt :)&lt;br /&gt;&lt;br /&gt;Anyway, grab out my favourites:&amp;nbsp;ExecutorService, LinkedBlockingQueue and others, create a Runnable class, run in a while loop, poll (or take) from the queue, and based on the type of message in the queue, store that in some state in the Runnable implementing class, let&#39;s call that the Aggregator.&lt;br /&gt;&lt;br /&gt;(would have to be thread safe, so I need to think about locking, or use a concurrent map, key=type of message, value = list of some wrapper that holds the message plus the time you received it). Then if the message that comes in is of type FirstMessage, put it in the list in the map, if the message is of type SecondMessage, get the last put FirstMessage out of the map, combine the two, creating an AggregatedMessage, remove the handled messages from the data structure. Then I would be able to send that AggregatedMessage to something else, for that I would need to think of a way to call for instance some remoting API, web services or whatever you like, get a proxy to that from inside the Aggregator, need to wire that up in some kind of way. And of course I would need to find a way to get the Aggregator up and running in an ExecutorService, and be able to call it from the outside in a reasonable way. Of course I would need to think of how to start and stop the Aggregator, monitor it&#39;s health, be able to restart it if it fails, stuff like that.&lt;br /&gt;&lt;br /&gt;And then I need to unit test this on thread safety, calling the code from two threads to simulate the two streams of message types, making sure it really works, mock out the web service in and out, oh yeah write some WSDL, do some config of JAX-WS (oh crap that&#39;s synchronous by nature), probably finding out along the way that sometimes SecondMessage comes before FirstMessage, rounding the whole thing out...&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;And maybe I will use the ConcurrentLinkedQueue instead of the BlockingQueue, just to find out that my thread is tightly spinning in my while(!stop) loop when it&#39;s in production.. (yes that does happen.. time to add a Thread.sleep?)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And that&#39;s only the aggregator, I haven&#39;t covered the two processes yet that need to take place before it (the ones I didn&#39;t draw in the diagram..)&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;I&#39;m actually already getting tired writing about it, let alone writing the actual code!&lt;br /&gt;&lt;br /&gt;Anyway, this post was about akka, so how would I do something like this using Actors?&lt;br /&gt;&lt;br /&gt;Well, a first try at it would be something like this:&lt;br /&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.Date&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.matchers.MustMatchers&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.Spec&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.actor.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SupervisorFactory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ActorRegistry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.actor.Actor._&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.config.ScalaConfig._&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SecondMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AggregateMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GiveMeLastMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Aggregator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pass&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receive&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;SecondMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Aggregator, my data is &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;firstMessageHandler&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ActorRegistry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actorsFor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;classOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;FirstMessageHandler&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;FirstMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;firstMessageHandler&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GiveMeLastMessage&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isDefined&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;FirstMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Aggregator, my first message is &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ag&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AggregateMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;pass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ag&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SecondMessageHandler&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receive&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;SecondMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;// do some processing&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Secondmessage, my data is &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;// then call the aggregator&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;aggregator&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ActorRegistry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actorsFor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;classOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Aggregator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;aggregator&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstMessageHandler&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lastMessage&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;FirstMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lastRequestor&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Any&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receive&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;FirstMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;c1&quot;&gt;// do some processing&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Firstmessage, my name is &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;lastMessage&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lastRequestor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lastRequestor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asInstanceOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;lastMessage&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;None&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;GiveMeLastMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lastMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isDefined&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;lastRequestor&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;senderFuture&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lastMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AggregatorSpec&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Spec&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MustMatchers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;aggregateMessageReceived&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;aggregateMessage&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;AggregateMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;An Aggregator&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;(when it receives FirstMessage and then SecondMessage)&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstMessageHandler&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;second&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SecondMessageHandler&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receiveTest&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;AggregateMessage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;n&quot;&gt;aggregateMessageReceived&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;n&quot;&gt;aggregateMessage&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;aggregator&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Aggregator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;receiveTest&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;second&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;aggregator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;should send an AggregateMessage containing data of FirstMessage and SecondMessage to the passed in actor&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;first&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;id-1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;name-1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;second&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SecondMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;data-1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;aggregateMessageReceived&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;aggregateMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;id-1&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;aggregateMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;name-1&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;aggregateMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;data-1&quot;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;second&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;aggregator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;What I really like about it is that I can try something like this out in very few lines of code. And, the solution is quite simple. When receiving the SecondMessage type in Aggregator you can ask the FirstMessageHandler to give you the last message it received, and inside that Actor, you use the senderFuture to respond back to the Aggregator! this is of course a very rough first try at it and should expand the test to run from many threads etc, but it hardly took me any time to write.</description><link>http://roestenburg.agilesquad.com/2010/05/join-messages-with-akka.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_8SomWRym6Jg/S-MWADnM6BI/AAAAAAAAAYc/AKCYkS1IxWc/s72-c/aggregator.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-5601345522201798025</guid><pubDate>Tue, 04 May 2010 21:06:00 +0000</pubDate><atom:updated>2010-11-29T17:18:23.378+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Akka</category><category domain="http://www.blogger.com/atom/ns#">Scala</category><title>Starting with Akka part 2, Intellij IDEA, Test Driven Development</title><description>&lt;b&gt;Update to this post:&amp;nbsp;&lt;/b&gt;I have upgraded the examples to Akka 1.0-RC1.&lt;a href=&quot;http://roestenburg.agilesquad.com/2010/07/upgrading-to-akka-master-010-and-scala.html&quot;&gt;&amp;nbsp;this newer post&lt;/a&gt;&amp;nbsp;might be more helpful, or check directly at github &lt;a href=&quot;http://github.com/RayRoestenburg/AkkaExamples&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In this post I&#39;m going to expand on the previous post&#39;s simple project, add the use of an IDE, and do some Test Driven Development with akka (with scalatest+junit)&lt;br /&gt;&lt;br /&gt;First, check if your Project.scala file has the dependencies for scalatest and junit:&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sbt._&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ProjectInfo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DefaultWebProject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;){&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;repositories&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Java.Net&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://download.java.net/maven/2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;jBoss&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://repository.jboss.org/maven2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;service mix&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://svn.apache.org/repos/asf/servicemix/m2-repo/&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Apache Camel&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;https://repository.apache.org/content/repositories/releases/&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Akka Maven Repository&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://scalablesolutions.se/akka/repository&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Multiverse Releases&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://multiverse.googlecode.com/svn/maven-repository/releases/&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;GuiceyFruit&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://guiceyfruit.googlecode.com/svn/repo/releases/&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;DataBinder&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://databinder.net/repo&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Configgy&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://www.lag.net/repo&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ScalaToolsSnapshots&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;libraryDependencies&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;cm&quot;&gt;/* servlet implementation */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;org.eclipse.jetty&quot;&lt;/span&gt; &amp;nbsp;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;jetty-server&quot;&lt;/span&gt; &amp;nbsp; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;7.0.1.v20091125&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;org.eclipse.jetty&quot;&lt;/span&gt; &amp;nbsp;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;jetty-webapp&quot;&lt;/span&gt; &amp;nbsp; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;7.0.1.v20091125&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;s&quot;&gt;&quot;org.scalatest&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;scalatest&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;1.0.1-for-scala-2.8.0.Beta1-with-test-interfaces-0.3-SNAPSHOT&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test-&amp;gt;default&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&lt;/span&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;cm&quot;&gt;/* camel */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;org.apache.camel&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;camel-ftp&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;2.2.0&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;cm&quot;&gt;/* akka dependencies */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;se.scalablesolutions.akka&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;akka-kernel_2.8.0.Beta1&quot;&lt;/span&gt; &amp;nbsp;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.8.1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;se.scalablesolutions.akka&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;akka-core_2.8.0.Beta1&quot;&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.8.1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;se.scalablesolutions.akka&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;akka-servlet_2.8.0.Beta1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.8.1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;se.scalablesolutions.akka&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;akka-rest_2.8.0.Beta1&quot;&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.8.1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;jettyPort&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9012&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;junit&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;junit&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;junit&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;4.5&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As you can see I have also added a dependency to Camel FTP2, a Camel component for FTP, which I will be using in my next post.&lt;br /&gt;&lt;br /&gt;At the moment I am using Intellij IDEA Community Edition EAP with the Scala Plugin for 2.8.0.Beta1. The EAP edition does come with a warning from jetbrains: &quot;Please note that the quality of EAP versions may at times be way below even usual beta standards&quot;.&lt;br /&gt;&lt;br /&gt;The Eclipse plugin is not usable at the moment, at least it didn&#39;t work for me. I did notice that IDEA was storing a +800MB index file somewhere in my home directory, which is kind of freaky, and compilation is a bit slow. I&#39;m going to investigate later what I will lose by using a simpler editor and doing everything through sbt scripting. But for now I&#39;m happy to use IDEA.&lt;br /&gt;&lt;br /&gt;(&lt;a href=&quot;http://b.wardje.eu/post/451394722&quot;&gt;Here&lt;/a&gt; is a good tip to add scala highlighting to gedit.)&lt;br /&gt;&lt;br /&gt;First download the IDEA Community Edition EAP and install:&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ wget http://download.jetbrains.com/idea/ideaIC-95.54.tar.gz&lt;br /&gt;$ sudo mkdir /usr/share/idea&lt;br /&gt;$ sudo cp ideaIC-95.54.tar.gz /usr/share/idea&lt;br /&gt;$ cd /usr/share/idea&lt;br /&gt;$ tar xvf ideaIC-95.54.tar.gz&lt;br /&gt;$ cd /usr/local/bin&lt;br /&gt;$ sudo ln -s /usr/share/idea/idea-IC-95.54/bin/idea.sh &lt;br /&gt;&lt;br /&gt;  &lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Then run idea so that it creates a .IdeaIC90 directory in your home directory.&lt;br /&gt;add a plugins directory to this directory:&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ cd ~/.IdeaIC90/config&lt;br /&gt;$ mkdir plugins&lt;br /&gt;  &lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Then download and install the latest scala plugin (at the moment scala-intellij-bin-0.3.1156.zip):&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ wget &#39;http://plugins.intellij.net/plugin/?action=download&amp;amp;id=8152&#39; -O scala-plugin.zip&lt;br /&gt;$ cp scala-plugin.zip .IdeaIC90/config/plugins&lt;br /&gt;$ cd .IdeaIC90/config/plugins/&lt;br /&gt;$ unzip scala-plugin.zip&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now run Idea, you should see the Scala plugin in the Plugins section. Create a new project from scratch, create it in the directory where your project is (in my case ~/akka_start):&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/_8SomWRym6Jg/S8yt9gCzbpI/AAAAAAAAAXU/1urpOgfYCP8/s1600/project-1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;http://4.bp.blogspot.com/_8SomWRym6Jg/S8yt9gCzbpI/AAAAAAAAAXU/1urpOgfYCP8/s640/project-1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/_8SomWRym6Jg/S8yuFDSCkBI/AAAAAAAAAXc/2xlS6fJQGp8/s1600/project-2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;http://1.bp.blogspot.com/_8SomWRym6Jg/S8yuFDSCkBI/AAAAAAAAAXc/2xlS6fJQGp8/s640/project-2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/_8SomWRym6Jg/S8yuJECky4I/AAAAAAAAAXk/zd3TOU59FNM/s1600/project-3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;http://3.bp.blogspot.com/_8SomWRym6Jg/S8yuJECky4I/AAAAAAAAAXk/zd3TOU59FNM/s640/project-3.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/_8SomWRym6Jg/S8yuZcGjxAI/AAAAAAAAAXs/AW-w4-m-_zM/s1600/project-5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;http://3.bp.blogspot.com/_8SomWRym6Jg/S8yuZcGjxAI/AAAAAAAAAXs/AW-w4-m-_zM/s640/project-5.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/_8SomWRym6Jg/S8yufZwos5I/AAAAAAAAAX0/drrl-4BXM3Q/s1600/project-7.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;http://4.bp.blogspot.com/_8SomWRym6Jg/S8yufZwos5I/AAAAAAAAAX0/drrl-4BXM3Q/s640/project-7.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Before I had some issues that IDEA would take the wrong scala facets and version, if that happens to you, check here:&lt;br /&gt;&lt;a href=&quot;http://www.jetbrains.net/devnet/thread/284354&quot;&gt;http://www.jetbrains.net/devnet/thread/284354&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Also, if the facet is not automatically included in your project, or you didn&#39;t check the Scala tickbox in the project wizard, open the .iml file in an editor (not in IDEA, it will be replaced) and add the facets so you get something like this (add the FacetManager part):&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;module&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;JAVA_MODULE&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;version=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;4&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;component&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;FacetManager&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;facet&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Scala&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Scala&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nt&quot;&gt;&amp;lt;option&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;takeFromSettings&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nt&quot;&gt;&amp;lt;option&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;myScalaCompilerJarPaths&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;nt&quot;&gt;&amp;lt;array&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;nt&quot;&gt;&amp;lt;option&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;$MODULE_DIR$/lib/scala-compiler.jar&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;nt&quot;&gt;&amp;lt;/array&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nt&quot;&gt;&amp;lt;option&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;myScalaSdkJarPaths&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;nt&quot;&gt;&amp;lt;array&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;nt&quot;&gt;&amp;lt;option&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;$MODULE_DIR$/lib/scala-library.jar&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;nt&quot;&gt;&amp;lt;/array&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/facet&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/component&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;component&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;NewModuleRootManager&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;inherit-compiler-output=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;exclude-output&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;content&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;url=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;file://$MODULE_DIR$&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;sourceFolder&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;url=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;file://$MODULE_DIR$/src/main/scala&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;isTestSource=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;sourceFolder&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;url=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;file://$MODULE_DIR$/src/test/scala&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;isTestSource=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/content&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;orderEntry&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;inheritedJdk&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;orderEntry&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;sourceFolder&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;forTests=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;orderEntry&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;library&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;scala-2.8.0.Beta1&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;level=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;application&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;orderEntry&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;library&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;akka&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;level=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;project&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/component&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/module&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now add the source and test folders in the project structure dialog:&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/_8SomWRym6Jg/S8ywaP6OMZI/AAAAAAAAAX8/BMXUTLpWskk/s1600/project-9.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;http://1.bp.blogspot.com/_8SomWRym6Jg/S8ywaP6OMZI/AAAAAAAAAX8/BMXUTLpWskk/s640/project-9.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/_8SomWRym6Jg/S8ywe44M-II/AAAAAAAAAYE/LFcLyaYw6H0/s1600/project-10.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;http://2.bp.blogspot.com/_8SomWRym6Jg/S8ywe44M-II/AAAAAAAAAYE/LFcLyaYw6H0/s640/project-10.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/_8SomWRym6Jg/S8ywlTAFBVI/AAAAAAAAAYM/V4vXGX64PdY/s1600/project-11.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;http://1.bp.blogspot.com/_8SomWRym6Jg/S8ywlTAFBVI/AAAAAAAAAYM/V4vXGX64PdY/s640/project-11.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;And add the dependency to the jars in lib_managed/scala_2.8.0.Beta1/compile&lt;br /&gt;If you followed the previous post, rebuild project should now complete with no errors, code completion should work and you are ready to go :)&lt;br /&gt;&lt;br /&gt;As I said before, the IDEA scala compiler is a bit slow, so at the moment I don&#39;t compile after every change in IDEA. I keep this cool sbt feature running in a terminal:&lt;br /&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ sbt&lt;br /&gt;$ ~test-quick&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The ~ makes test-quick running as a triggered action, and compiles and runs all failed or dependent tests when any source modification is done.&lt;br /&gt;&lt;br /&gt;I wrote a small test just to check if everything is working. (You would normally of course never put the test code and the scala code together in one file, but its simpler to read here)&lt;br /&gt;&lt;br /&gt;The test starts a &quot;Worker&quot; Actor, queues a few Commands, and then checks the amount of commands that are queued in the worker, and checks if all commands are executed. I&#39;m using the MustMatchers for the nice syntax (&#39;must be&#39; matcher). The red-green-refactor flow is very nice while using the ~test-quick command.&lt;br /&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.Spec&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;org.scalatest.matchers.MustMatchers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.actor.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountCommandsQueued&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Execute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Nil&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receive&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Command&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Execute&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dropRight&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;CountCommandsQueued&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountResponse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;WorkerSpec&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Spec&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MustMatchers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;A Worker&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;(when it queues commands)&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;should have the correct number of commands queued&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;CountResponse&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountCommandsQueued&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getOrElse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountCommandsQueued&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getOrElse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;(when it executes all queued commands)&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;should have no commands queued after executing&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Worker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;command&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;k&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;CountResponse&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountCommandsQueued&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getOrElse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Execute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CountCommandsQueued&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getOrElse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fail&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;must&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;n&quot;&gt;actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stop&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;br /&gt;&lt;/code&gt;</description><link>http://roestenburg.agilesquad.com/2010/05/starting-with-akka-part-2-intellij-idea.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_8SomWRym6Jg/S8yt9gCzbpI/AAAAAAAAAXU/1urpOgfYCP8/s72-c/project-1.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-1622791424074755359</guid><pubDate>Sat, 17 Apr 2010 12:49:00 +0000</pubDate><atom:updated>2010-11-29T17:16:52.682+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Akka</category><category domain="http://www.blogger.com/atom/ns#">Scala</category><title>Starting with Akka and Scala</title><description>&lt;b&gt;Update to this post: &lt;/b&gt;I have upgraded the examples to Akka 1.0-RC1.&lt;a href=&quot;http://roestenburg.agilesquad.com/2010/07/upgrading-to-akka-master-010-and-scala.html&quot;&gt; this newer post&lt;/a&gt; might be more helpful.&lt;br /&gt;&lt;br /&gt;I recently started playing around with Scala. I had read a lot about Scala before but never got around really doing anything with it. I was looking for some (probably Java) libraries that would make a couple of things really easy:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Easy concurrency&lt;/li&gt;&lt;li&gt;Interop with Java or in Java&lt;/li&gt;&lt;li&gt;Distributed computing nodes&lt;/li&gt;&lt;li&gt;Event driven&lt;/li&gt;&lt;li&gt;Highly scalable&lt;/li&gt;&lt;li&gt;Low bandwidth usage for communicating between nodes (so no XML)&lt;/li&gt;&lt;li&gt;Pluggable data format&lt;/li&gt;&lt;li&gt;Easy development of message exchanges, asynchronous, one way, two way, synchronous, etc&lt;/li&gt;&lt;li&gt;Possible (but hopefully not necessary) distributed state/database&lt;/li&gt;&lt;li&gt;Reliable when failures happen&lt;/li&gt;&lt;li&gt;Easy integration with a range of communication protocols / endpoints&lt;/li&gt;&lt;/ul&gt;At first I found&amp;nbsp;&lt;a href=&quot;http://bsonspec.org/&quot;&gt;BSON&lt;/a&gt;&amp;nbsp;as a data format, as part of the mongodb project. Quick after that I found&amp;nbsp;&lt;a href=&quot;http://code.google.com/p/protobuf/&quot;&gt;Google Protobuf&lt;/a&gt;&amp;nbsp;which was a better candidate for me. That lead me to &lt;a href=&quot;http://www.jboss.org/netty&quot;&gt;JBoss Netty&lt;/a&gt;, which supports protobuf out of the box. Netty was a bit too low level for my needs this time and by chance I saw a tweet come by from&lt;a href=&quot;http://twitter.com/deanwampler&quot;&gt; Dean Wampler&lt;/a&gt;, &#39;&lt;a href=&quot;http://akkasource.org/&quot;&gt;Akka&lt;/a&gt; 0.7 released&#39;. Didn&#39;t know what it was (&lt;a href=&quot;http://akkasource.org/&quot;&gt;Akka&lt;/a&gt; is apparently a mountain in Sweden) checked it out, and to my surprise Akka uses JBoss Netty and protobuf for Remote Actors! If you look at the many (pluggable)&amp;nbsp;&lt;a href=&quot;http://akkasource.org/&quot;&gt;features&lt;/a&gt; of Akka it&#39;s easy to get&amp;nbsp;enthusiastic&amp;nbsp;about it very quickly. I read through the source code, which (as far as I can tell at this moment of course) looks good. Plenty of tests, well structured, easy to read. There are some smart people behind this framework with the right know-how, which is very important as well.&lt;br /&gt;&lt;br /&gt;Akka does have a Java API, but once you see the Scala version, I don&#39;t think you will want to use it. That&#39;s got nothing to do with the quality of the Java API by the way, more the succinct way of expressing code and the amount of typing that you will save yourself from :). Well, for some years now I follow the rule to learn at least one new programming language every year, so this year I&#39;m adding Scala to the list.&lt;br /&gt;&lt;br /&gt;So I started with an Akka project, did some playing around with Eclipse, Intellij, maven, sbt, Scala of course, &lt;a href=&quot;http://camel.apache.org/&quot;&gt;Apache Camel&lt;/a&gt; integration. I used the&amp;nbsp;&lt;a href=&quot;http://github.com/efleming969/akka-template-rest&quot;&gt;akka-template-rest&lt;/a&gt;&amp;nbsp;template first to get started quickly. I quickly found out that the Scala Eclipse plugin is not really ready yet, so now I&#39;m using Intellij IDEA. in the next post I&#39;ll talk about the use of an IDE.&lt;br /&gt;&lt;br /&gt;Disclaimer: Since I&#39;m not a Scala expert (yet :) and I don&#39;t always work on linux I just got things to work to get the job done, if you have any tips for improvement let me know. I&#39;m using Ubuntu 9.10 Karmic Koala.&lt;br /&gt;&lt;br /&gt;Install &lt;a href=&quot;http://code.google.com/p/simple-build-tool/&quot;&gt;sbt&lt;/a&gt;&amp;nbsp;(&lt;a href=&quot;http://simple-build-tool.googlecode.com/files/sbt-launch-0.7.3.jar&quot;&gt;0.7.3&lt;/a&gt;):&lt;br /&gt;Follow the setup&amp;nbsp;&lt;a href=&quot;http://code.google.com/p/simple-build-tool/wiki/Setup&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;sbt will install scala inside the project that we will create.&amp;nbsp;Create a new project by running sbt in a newly created project:&lt;br /&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ mkdir akka_start&lt;br /&gt;$ cd akka_start&lt;br /&gt;$ sbt&lt;br /&gt;Project does not exist, create new project? (y/N/s) y&lt;br /&gt;Name: akka_start&lt;br /&gt;Organization: agilesquad&lt;br /&gt;Version [1.0]: &lt;br /&gt;Scala version [2.7.7]: 2.8.0.Beta1 &lt;br /&gt;sbt version [0.7.3]: &lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;It&#39;s very important to use 2.8.0.Beta1, the RC1 still has some issues. sbt itself is running on Scala 2.7.7.&lt;br /&gt;&lt;br /&gt;I find sbt a very nice tool so far, it is very similar to maven, can use maven dependencies, but you write your build file in Scala in an internal DSL, which is a lot nicer than XML.&lt;br /&gt;&lt;br /&gt;Lets write a simple project file:&lt;br /&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ cd ~/akka_start&lt;br /&gt;$ mkdir project/build&lt;br /&gt;$ gedit project/build/Project.scala&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Project.scala:&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sbt._&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ProjectInfo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DefaultWebProject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;){&lt;/span&gt;&lt;br /&gt; &lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;repositories&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;Java.Net&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://download.java.net/maven/2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;jBoss&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://repository.jboss.org/maven2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;service mix&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://svn.apache.org/repos/asf/servicemix/m2-repo/&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;Apache Camel&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;https://repository.apache.org/content/repositories/releases/&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;Akka Maven Repository&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://scalablesolutions.se/akka/repository&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;Multiverse Releases&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://multiverse.googlecode.com/svn/maven-repository/releases/&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;GuiceyFruit&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://guiceyfruit.googlecode.com/svn/repo/releases/&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;DataBinder&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://databinder.net/repo&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;Configgy&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://www.lag.net/repo&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nc&quot;&gt;ScalaToolsSnapshots&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;libraryDependencies&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;cm&quot;&gt;/* servlet implementation */&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;org.eclipse.jetty&quot;&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;jetty-server&quot;&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;7.0.1.v20091125&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;org.eclipse.jetty&quot;&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;jetty-webapp&quot;&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;7.0.1.v20091125&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;s&quot;&gt;&quot;org.scalatest&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;scalatest&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;1.0.1-for-scala-2.8.0.Beta1-with-test-interfaces-0.3-SNAPSHOT&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test-&amp;gt;default&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;cm&quot;&gt;/* camel */&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;org.apache.camel&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;camel-ftp&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;2.2.0&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;cm&quot;&gt;/* akka dependencies */&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;se.scalablesolutions.akka&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;akka-kernel_2.8.0.Beta1&quot;&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.8.1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;se.scalablesolutions.akka&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;akka-core_2.8.0.Beta1&quot;&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.8.1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;se.scalablesolutions.akka&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;akka-servlet_2.8.0.Beta1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.8.1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;s&quot;&gt;&quot;se.scalablesolutions.akka&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;akka-rest_2.8.0.Beta1&quot;&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.8.1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt; &lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;jettyPort&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9012&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;junit&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;junit&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;junit&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;4.5&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I am not using any distributed database yet so I removed those dependencies (redis etc). I have already added some dependencies that I will use in the next post (camel-ftp2, junit, scalatest). As you can see I am using akka 0.8.1 which is dependent on Scala 2.8.0.Beta1 at the moment.&lt;br /&gt;&lt;br /&gt;update the project dependencies:&lt;br /&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ cd ~/akka_start&lt;br /&gt;$ sbt update&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You will now find a lib_managed directory in your project directory.&lt;br /&gt;Add a webapp:&lt;br /&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ cd ~/akka_start/src/main&lt;br /&gt;$ mkdir webapp&lt;br /&gt;$ mkdir webapp/WEB-INF&lt;br /&gt;$ cd webapp/WEB-INF&lt;br /&gt;$ gedit web.xml&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;web.xml:&lt;br /&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE web-app PUBLIC &quot;-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;cp&quot;&gt; &quot;http://java.sun.com/dtd/web-app_2_4.dtd&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;web-app&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;listener&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;listener-class&amp;gt;&lt;/span&gt;se.scalablesolutions.akka.servlet.Initializer&lt;span class=&quot;nt&quot;&gt;&amp;lt;/listener-class&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/listener&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;servlet&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;servlet-name&amp;gt;&lt;/span&gt;AkkaServlet&lt;span class=&quot;nt&quot;&gt;&amp;lt;/servlet-name&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;servlet-class&amp;gt;&lt;/span&gt;se.scalablesolutions.akka.rest.AkkaServlet&lt;span class=&quot;nt&quot;&gt;&amp;lt;/servlet-class&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/servlet&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;servlet-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;servlet-name&amp;gt;&lt;/span&gt;AkkaServlet&lt;span class=&quot;nt&quot;&gt;&amp;lt;/servlet-name&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;url-pattern&amp;gt;&lt;/span&gt;/*&lt;span class=&quot;nt&quot;&gt;&amp;lt;/url-pattern&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/servlet-mapping&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/web-app&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Check if a WAR is being created:&lt;br /&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ cd ~/akka_start&lt;br /&gt;$ sbt package&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Add a akka.conf to the resources:&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ cd ~/akka_start/src/main/resources&lt;br /&gt;$ gedit akka.conf&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;akka.conf:&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;####################&lt;br /&gt;# Akka Config File #&lt;br /&gt;####################&lt;br /&gt;&lt;br /&gt;# This file has all the default settings, so all these could be removed with no visible effect.&lt;br /&gt;# Modify as needed.&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;log&amp;gt;&lt;/span&gt;&lt;br /&gt;  filename = &quot;./logs/akka.log&quot;&lt;br /&gt;  roll = &quot;daily&quot;  # Options: never, hourly, daily, sunday/monday/...&lt;br /&gt;  level = &quot;info&quot; # Options: fatal, critical, error, warning, info, debug, trace&lt;br /&gt;  console = on&lt;br /&gt;  # syslog_host = &quot;&quot;&lt;br /&gt;  # syslog_server_name = &quot;&quot;&lt;br /&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/log&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;akka&amp;gt;&lt;/span&gt;&lt;br /&gt;  version = &quot;0.8.1&quot;&lt;br /&gt;&lt;br /&gt;  # FQN to the class doing initial active object/actor&lt;br /&gt;  # supervisor bootstrap, should be defined in default constructor&lt;br /&gt;  boot = [&quot;com.agilesquad.Boot&quot;]&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;actor&amp;gt;&lt;/span&gt;&lt;br /&gt;    timeout = 5000              # default timeout for future based invocations&lt;br /&gt;    serialize-messages = off    # does a deep clone of (non-primitive) messages to ensure immutability&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/actor&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;stm&amp;gt;&lt;/span&gt;&lt;br /&gt;    service = on&lt;br /&gt;    fair = on                     # should transactions be fair or non-fair (non fair yield better performance)&lt;br /&gt;    max-nr-of-retries = 1000      # max nr of retries of a failing transaction before giving up&lt;br /&gt;    timeout = 10000               # transaction timeout; if transaction has not committed within the timeout then it is aborted&lt;br /&gt;    distributed = off             # not implemented yet&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/stm&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;remote&amp;gt;&lt;/span&gt;&lt;br /&gt;    compression-scheme = &quot;zlib&quot; # Options: &quot;zlib&quot; (lzf to come), leave out for no compression&lt;br /&gt;    zlib-compression-level = 6  # Options: 0-9 (1 being fastest and 9 being the most compressed), default is 6&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;cluster&amp;gt;&lt;/span&gt;&lt;br /&gt;      service = on&lt;br /&gt;      name = &quot;default&quot;                                                        # The name of the cluster&lt;br /&gt;      actor = &quot;se.scalablesolutions.akka.cluster.jgroups.JGroupsClusterActor&quot; # FQN of an implementation of ClusterActor&lt;br /&gt;      serializer = &quot;se.scalablesolutions.akka.serialization.Serializer$Java$&quot; # FQN of the serializer class&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/cluster&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;server&amp;gt;&lt;/span&gt;&lt;br /&gt;      service = on&lt;br /&gt;      hostname = &quot;localhost&quot;&lt;br /&gt;      port = 9999&lt;br /&gt;      connection-timeout = 1000 # in millis (1 sec default)&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;server&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;client&amp;gt;&lt;/span&gt;&lt;br /&gt;      reconnect-delay = 5000    # in millis (5 sec default)&lt;br /&gt;      read-timeout = 10000      # in millis (10 sec default)&lt;br /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;client&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/remote&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/akka&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;In the akka.conf you need to specify your boot class, in this case com.agilesquad.Boot&lt;br /&gt;(boot = [&quot;com.agilesquad.Boot&quot;])&lt;br /&gt;&lt;br /&gt;Now write a very simple Actor to test if it runs (inside jetty). I have chosen to write an Actor that integrates with an Apache Camel file endpoint.&lt;br /&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ cd src/main/scala/&lt;br /&gt;$ gedit Boot.scala &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Boot.scala:&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;span class=&quot;k&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.agilesquad&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.actor.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SupervisorFactory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.camel.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Consumer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;se.scalablesolutions.akka.config.ScalaConfig._&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Boot&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;   &lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;factory&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SupervisorFactory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;nc&quot;&gt;SupervisorConfig&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;br /&gt;   &lt;span class=&quot;nc&quot;&gt;RestartStrategy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;OneForOne&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;classOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Exception&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])),&lt;/span&gt;&lt;br /&gt;   &lt;span class=&quot;nc&quot;&gt;Supervise&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CamelConsumer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;LifeCycle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Permanent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Nil&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;n&quot;&gt;factory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;newInstance&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CamelConsumer&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Actor&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Consumer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;endpointUri&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;file:///home/rroestenburg/input&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receive&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;received camel message...&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;For simplicity I have just added all the classes in the Boot.scala file.&lt;br /&gt;&lt;br /&gt;Now run sbt without arguments, execute compile, execute jetty-run&lt;br /&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;code class=&quot;syntax&quot;&gt;&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class=&quot;syntax&quot;&gt;$ sbt &lt;br /&gt;$ compile&lt;br /&gt;$ jetty-run&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You should now have a running akka server! as shown above the endpointUri is pointing to an input directory of your choice (in &amp;nbsp;my case /home/rroestenburg/input), copy a file in there and check if the message ends up in the logging (&quot;received camel message).&lt;br /&gt;&lt;br /&gt;That&#39;s it for now, in the next post I&#39;ll get into the use of Intellij IDEA Community Edition with the latest Scala Plugin for 2.8.0.Beta1, as well as some Test Driven Development with Scala and Akka, and how to use some extra Camel components.</description><link>http://roestenburg.agilesquad.com/2010/04/starting-with-akka-and-scala.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-7456747793590205717</guid><pubDate>Fri, 16 Oct 2009 18:48:00 +0000</pubDate><atom:updated>2009-10-16T20:57:50.378+02:00</atom:updated><title>Executing XPath from the command line</title><description>I had to check some large (SOAP) XML files the other day and was wondering if there was an easy command line tool to execute XPath expressions. I found xmllint in my Cygwin install, and it happened to be installed on the linux servers I was working on.&lt;br /&gt;&lt;br /&gt;It&#39;s actually quite easy to use:&lt;br /&gt;xmllint --noent --shell file.xml&lt;br /&gt;&lt;br /&gt;That opens up a shell in which you can do many things, but at the time I was only interested in running some XPath expressions. The first thing you run into is that namespaces can get in your way with XPath. You need to register the namespaces in the XML to prefixes that can be used in the XPath context. &lt;br /&gt;In the shell you can use this command to for instance register soap:&lt;br /&gt;/ &gt; setns soap=http://schemas.xmlsoap.org/soap/envelope/&lt;br /&gt;&lt;br /&gt;after that you can run xpath expressions, some simple examples:&lt;br /&gt;&lt;br /&gt;/ &gt; xpath soap:Envelope&lt;br /&gt;/ &gt; xpath count(//mynamespace:myElement)&lt;br /&gt;&lt;br /&gt;Quite a handy little tool.</description><link>http://roestenburg.agilesquad.com/2009/10/executing-xpath-from-command-line.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-8667435007150342654</guid><pubDate>Fri, 08 May 2009 09:20:00 +0000</pubDate><atom:updated>2009-05-08T11:38:26.158+02:00</atom:updated><title>Quick notes to self on java.io</title><description>Just a quick post so that I don&#39;t forget next time:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;java.io.FilterOutputStream&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you extend &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/io/FilterInputStream.html&quot;&gt;java.io.FilterOutputStream&lt;/a&gt;, don&#39;t forget to override &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html#write(byte[], int, int)&quot;&gt;write(byte b[], int off, int len)&lt;/a&gt;, since the default implementation falls back on looping &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html#write(int)&quot;&gt;write(byte b)&lt;/a&gt; which is terribly slow.&lt;br /&gt;Also, when you also override &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html#write(byte[])&quot;&gt;write(byte[] b)&lt;/a&gt;, make sure to call write(b,0,b.length); and not the super method:&lt;br /&gt;&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;&lt;br /&gt;@Override&lt;br /&gt;public void write(byte[] b) throws IOException {&lt;br /&gt;  write(b,0,b.length);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Readers, Writers, Streams, that delegate to underlying source.&lt;/span&gt;&lt;br /&gt;Always check if the implementation of the close() method, closes the underlying source automatically. Don&#39;t assume that it always will.&lt;br /&gt;&lt;a href=&quot;http://java.sun.com/webservices/docs/1.5/api/javax/xml/stream/XMLStreamReader.html&quot;&gt;XMLStreamReader&lt;/a&gt; for instance, doesn&#39;t close the underlying source. &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html#close()&quot;&gt;FilterOutputStream&lt;/a&gt; does. &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/io/BufferedWriter.html#close()&quot;&gt;BufferedWriter&lt;/a&gt; does. &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html#close()&quot;&gt;BufferedReader&lt;/a&gt; does. &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/util/zip/GZIPInputStream.html#close()&quot;&gt;GZIPInputStream&lt;/a&gt; does.&lt;br /&gt;(In my opinion this should be consistent, but it is not.)</description><link>http://roestenburg.agilesquad.com/2009/05/quick-notes-to-self-on-javaio.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-1154553163620047956</guid><pubDate>Wed, 08 Oct 2008 15:55:00 +0000</pubDate><atom:updated>2008-10-08T18:10:30.466+02:00</atom:updated><title>Firefox and stylesheet link mime-type</title><description>I found out that Firefox is a bit more strict than Internet Explorer when it comes to stylesheet links. I had one of the stylesheet files up on googlecode, in the downloads/files section. I&#39;m hosting the blog completely on free servers, so I had to find a place to put the Syntax Highlighter stuff. For a while now I saw that the code on the blog was not shown correctly in Firefox, although it did show correctly in IE and thought &#39;pfff&#39;. Until someone nagged me about it (thanks Marc).&lt;br /&gt;&lt;br /&gt;Seams I had an error on my page, Firefox didn&#39;t like the mime-type of the file that was hosted on googlecode downloads. Reported that the mime-type was ‘text/x-c’, not ‘text/css’. Must be the default mime-type that is used to serve files from googlecode. &lt;br /&gt;&lt;br /&gt;As far as I know, you can&#39;t control the mime-type for files in the googlecode downloads section. The solution is quite simple though, I moved the css file to the source section (svn) and added an &#39;svn:mime-type&#39; property to the file. I used tortoisesvn for it, right click on the file, properties, add property with name &#39;svn:mime-type&#39; and value &#39;text/css&#39;, commit. That way the file is served with the correct mime-type.</description><link>http://roestenburg.agilesquad.com/2008/10/firefox-and-stylesheet-link-mime-type.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-8406830040179415516</guid><pubDate>Tue, 16 Sep 2008 07:43:00 +0000</pubDate><atom:updated>2008-10-05T11:36:51.637+02:00</atom:updated><title>Note on WCF behavior extension element</title><description>As described here: &lt;a href=&quot;http://decav.com/blogs/andre/archive/2007/11/06/wcf-configurationerrorsexception-when-defining-behavior-extensions.aspx&quot;&gt;about configuration errors when defining behavior extensions&lt;/a&gt;, there is a &lt;a href=&quot;https://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=216431&quot;&gt;bug&lt;/a&gt; that makes it necessary to fully specifiy the class and assembly name in your behavior extension:&lt;br /&gt;&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;xml&quot;&gt;&lt;br /&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;&amp;lt;!-- configuration, servicemodel etc. left out for clarity--&amp;gt;&lt;br /&gt;&amp;lt;extensions&amp;gt;&lt;br /&gt;  &amp;lt;behaviorExtensions&amp;gt;&lt;br /&gt;  &amp;lt;!-- Because of a bug in .NET framework you need to fully specify the behavior class and assembly&lt;br /&gt;--&amp;gt;&lt;br /&gt;    &amp;lt;add name=&quot;springBehavior&quot;&lt;br /&gt;            type=&quot;AgileSquad.Wcf.Spring.SpringServiceBehavior, AgileSquad.Wcf.Spring, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a44c692614ed00fa&quot;/&amp;gt;&lt;br /&gt;  &amp;lt;/behaviorExtensions&amp;gt;&lt;br /&gt;&amp;lt;/extensions&amp;gt;&lt;br /&gt;&lt;/pre&gt;</description><link>http://roestenburg.agilesquad.com/2008/09/note-on-wcf-behavior-extension-element.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-9167075038411179028</guid><pubDate>Sat, 13 Sep 2008 07:21:00 +0000</pubDate><atom:updated>2008-09-14T10:28:28.719+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Dependency Injection</category><category domain="http://www.blogger.com/atom/ns#">NUnit</category><category domain="http://www.blogger.com/atom/ns#">Spring.NET</category><category domain="http://www.blogger.com/atom/ns#">WCF</category><title>Update on WCF service dependency injection using Spring.NET</title><description>I have just uploaded the code that I use for DI in combination with WCF, using Spring.Net.&lt;br /&gt;(better late than never!)&lt;br /&gt;&lt;br /&gt;It&#39;s up on &lt;a href=&quot;http://code.google.com/p/agilesquadblog/&quot;&gt;http://code.google.com/p/agilesquadblog/&lt;/a&gt;.&lt;br /&gt;When you svn checkout it is in the AgileSquad.Wcf subfolder.&lt;br /&gt;&lt;br /&gt;The instance provider itself is basically a copy/paste out of Oran Dennison&#39;s blog.&lt;br /&gt;I have only changed the ReleaseInstance method to dispose of the instance (the service implementation) if it implements IDisposable:&lt;br /&gt;&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;&lt;br /&gt;public void ReleaseInstance(InstanceContext instanceContext, object instance)&lt;br /&gt;{&lt;br /&gt;  IDisposable disposable = instance as IDisposable;&lt;br /&gt;  if(disposable!=null)&lt;br /&gt;  {&lt;br /&gt;    disposable.Dispose();&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Additional to that the source code includes a working example (visual studio 2008 solution) of the instance provider, test service and configuration.&lt;br /&gt;It includes unit tests to test the spring instance provider.&lt;br /&gt;&lt;br /&gt;It also includes some interfaces that I use to abstract the use of WCF channel factory proxies and generated client classes.&lt;br /&gt;&lt;br /&gt;The idea behind that is that I don&#39;t want my code to reference implementation directly, cause it makes testing more difficult.&lt;br /&gt;&lt;br /&gt;So instead of something like:&lt;br /&gt;&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;&lt;br /&gt;using (var generatedWcfClient = new GeneratedWcfClient(&quot;endPoint&quot;))&lt;br /&gt;{&lt;br /&gt;  generatedWcfClient.SendMessage(message);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I use something like:&lt;br /&gt;&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;&lt;br /&gt;using (IServiceProxy&amp;lt;IMyService&amp;gt; proxy = factory.CreateProxy())&lt;br /&gt;{&lt;br /&gt;  proxy.Service.SendMessage(message);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In my Service Consumer code. (The factory in the above example is injected through DI of course, see the code)&lt;br /&gt;&lt;br /&gt;That means that the code that uses the proxies can be easily configured to use mock or in-memory implementations of the interfaces. It also decouples the use of the specific solution for communicating with a service (WCF in this case). The chance that I will change to some other implementation than WCF is obviously very small. But for testing and decoupling it is great in my opinion. It also decouples the choice of using a generated client or a channel factory.&lt;br /&gt;&lt;br /&gt;Check out the code for more details.&lt;br /&gt;&lt;br /&gt;The code also includes a ServiceTestEnvironment class that I use to easily test WCF Services. It hosts the WCF Service in a ServiceHost, and allows the unit test to call the service using a proxy and SetUp and TearDown the &quot;environment&quot;. In the Test project I use the above mentioned IServiceProxy and IServiceProxyFactory interfaces. The ChannelFactory implementation is used, as a generated proxy would start conflicting (ambiguous references)with the service code because you would have to reference both the client and the server in this way of testing.</description><link>http://roestenburg.agilesquad.com/2008/09/update-on-wcf-service-dependency.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-1872630811614046385</guid><pubDate>Sat, 13 Sep 2008 07:17:00 +0000</pubDate><atom:updated>2008-09-13T09:18:18.934+02:00</atom:updated><title>Firefox</title><description>I just found out my blog layout looks really weird on Firefox 3. Anybody any ideas?</description><link>http://roestenburg.agilesquad.com/2008/09/firefox.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-8495600208347860512</guid><pubDate>Fri, 08 Aug 2008 12:24:00 +0000</pubDate><atom:updated>2008-08-08T14:39:14.572+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Ruby</category><title>Ruby for building and testing C# code</title><description>Check out &lt;a href=&quot;http://www.infoq.com/interviews/IronRuby-John-Lam&quot;&gt;http://www.infoq.com/interviews/IronRuby-John-Lam&lt;/a&gt; for an interview with John Lam on IronRuby.&lt;br /&gt;&lt;br /&gt;What is interesting (amongst other things in the interview) is the view that you could start using Ruby in testing and building applications that are not necessarily written in Ruby, meaning using RSpec and rake to build and test for instance .NET applications . Because of the integration that IronRuby has with the .NET framework, if you needed to, you could do more .NET specific things in your build or test if you needed to.&lt;br /&gt;&lt;br /&gt;Sounds like a nice idea to build a continuous integration solution with this...</description><link>http://roestenburg.agilesquad.com/2008/08/ruby-for-building-and-testing-c-code.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-3583771809309769496</guid><pubDate>Sat, 12 Jul 2008 17:48:00 +0000</pubDate><atom:updated>2008-07-12T19:58:05.528+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Active Directory</category><category domain="http://www.blogger.com/atom/ns#">SVN</category><title>VisualSVN Server</title><description>After trying to get Subversion + Apache to work with Active Directory on Windows Server 2003 for quite a while, a colleague of mine pointed me at &lt;a href=&quot;http://www.visualsvn.com/server/&quot;&gt;http://www.visualsvn.com/server/&lt;/a&gt;. It&#39;s for free and comes with a nice user friendly management console. But more importantly (for me at least) is that it supports Active Directory out of the box, which saved me a lot of time figuring out how to setup and configure those Apache auth mods!&lt;br /&gt;&lt;br /&gt;The only thing I found strange is that the management console doesnt allow you to create repositories with a &#39;.&#39; in the name. Creating a repository with for instance underscores in the management console, and then renaming the repository folder on disk to use dots instead works fine though.</description><link>http://roestenburg.agilesquad.com/2008/07/visualsvn-server.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-291666483238298062</guid><pubDate>Fri, 11 Jul 2008 09:45:00 +0000</pubDate><atom:updated>2008-09-16T09:42:43.219+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">XNA</category><title>A simple XNA game</title><description>&lt;a href=&quot;http://bp1.blogger.com/_8SomWRym6Jg/SHd3xJKoSAI/AAAAAAAAAP0/vkA3EQdWcrw/s1600-h/trainers_245x340.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5221773979117176834&quot; style=&quot;FLOAT: right; MARGIN: 0px 0px 10px 10px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://bp1.blogger.com/_8SomWRym6Jg/SHd3xJKoSAI/AAAAAAAAAP0/vkA3EQdWcrw/s400/trainers_245x340.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; The company I work for (CSC) has updated their company logo and corporate image. Within this context I developed a little videogame with XNA with my colleague Mo&#39;in Creemers.&lt;br /&gt;&lt;br /&gt;Since CSC sponsors a team in the Tour de France, the marketing division thought it was a nice idea to make a videogame that uses a virtual trainer (&lt;a href=&quot;http://www.tacx.com/&quot;&gt;http://www.tacx.com/&lt;/a&gt;), which looks like the picture here on the right. The videogame will be used for a giveaway of a racing bicycle.&lt;br /&gt;&lt;br /&gt;First challenge we had to tackle is to communicate with the Tacx Virtual Trainer. While we were discussing reverse-engineering the device, sniffing the USB port and more &#39;high tech&#39; ideas, someone had a brilliant idea: Why not just call Tacx and ask them if they can&#39;t send us the API for it?&lt;br /&gt;&lt;br /&gt;Luckily Tacx was so kind to send us the DLL&#39;s to communicate with the virtual trainer, along with some testing tools!&lt;br /&gt;&lt;br /&gt;One challenge down, one to go: To build a playable game in less than 2 weeks.&lt;br /&gt;We still needed some cool graphics &amp;amp; audio and a game development environment that doesnt get in the way. And of course we still had to actually build something.&lt;br /&gt;&lt;br /&gt;The idea was to make a topdown view 2D racer game, where you ride around a little island, pickup gems as you go along. Every picked up gem fills in a piece of the new logo. The goal of the game is to complete the logo in time. You get a score for how fast you cycle and the gems randomly multiply your existing score from 1/8 till 8 times. So your final score is actually quite random (you need to pickup at least 9 gems), that way everyone has a chance to win the giveaway bicycle.&lt;br /&gt;&lt;br /&gt;We decided to keep it simple and use Microsoft XNA and go for 2D. XNA really is a great library for game development. It simplifies life in the right places (more on that later) and still gives you a lot of performance. We chose to use XNA Game Studio 2.0 (which installs on top of Visual Studio 2005). Game development environment, check!&lt;br /&gt;&lt;br /&gt;Since our graphic design skills are questionable at the least, and we really didn&#39;t have time to develop the code and design graphics in 2 weeks, we used some of Lostgarden/danc&#39;s graphics (Big up Danc!)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://bp1.blogger.com/_8SomWRym6Jg/SHd4HzjdW6I/AAAAAAAAAP8/VNGsA9Qy1ZM/s1600-h/BlockRPGMockup-772331.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5221774368452729762&quot; style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://bp1.blogger.com/_8SomWRym6Jg/SHd4HzjdW6I/AAAAAAAAAP8/VNGsA9Qy1ZM/s400/BlockRPGMockup-772331.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://lostgarden.com/2007/05/dancs-miraculously-flexible-game.html&quot;&gt;http://lostgarden.com/2007/05/dancs-miraculously-flexible-game.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As you can see the graphics are excellent.&lt;br /&gt;&lt;br /&gt;The cool thing is that Danc lets you download the graphics in Microsoft Expression Design format, which is vector based. Makes it a lot easier to modify than bitmaps, and the resulting quality is a lot better too. We tweaked the graphics a bit, probably for the worse :) I took the character in the middle of the picture above, took his face off, drew a cap in its place, gave him a bicycle and some legs (or at least thats what it&#39;s supposed to look like).&lt;br /&gt;Graphics, check!&lt;br /&gt;&lt;br /&gt;Now we need to get some nice audio. The graphics are really cute and bright and we needed some audio that would suit the graphics. So the first thing that came to mind was Super Mario. downloaded some samples and created a xap file. Audio, check!&lt;br /&gt;&lt;br /&gt;Now for development. We used a lot of the XNA creator club examples, like the SpaceWar example, Tiled Sprites, Collision Detection Series and SpriteSheet examples to get into XNA. The learning curve actually is not so steep at all. I built our own pipeline component to load the tiled layers. We use the SpriteSheet example pipeline and based our own pipelone project on it. I used Mappy (&lt;a href=&quot;http://www.tilemap.co.uk/mappy.php&quot;&gt;http://www.tilemap.co.uk/mappy.php&lt;/a&gt;) to create the layers, and exported it to text for easy loading of the &#39;baddies&#39; in the game and the playing field. I linked the id&#39;s in the 2-dimensional array to the id&#39;s in the spritesheet for passive layers. I linked the id&#39;s in a interactive layer to an enum, based on which a GameObjectFactory creates interactive objects in the games (basically the bugs, the road, water, gems, rocks, dirtroad and so on).&lt;br /&gt;&lt;br /&gt;All the interactive objects implement the following interface:&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;&lt;br /&gt;    public interface IInteractable : ITransformable, ISpriteDrawable&lt;br /&gt;    {&lt;br /&gt;        bool InteractWith(Player player);&lt;br /&gt;&lt;br /&gt;        void Update(GameTime gameTime);&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Most of the interactors extend an AbstractSpriteGameObject class, which draws itself and delegates to a PixelCollidable class to do collision detection.&lt;br /&gt;&lt;br /&gt;The Player class then has an InteractWith(..) for every type of object,&lt;br /&gt;double dispatch is sweet. The interactive objects can update themselves on every frame. The InteractWith method implementation on the interactive objects is mostly like:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;csharp&quot;&gt;&lt;br /&gt;if(player.Collidable.CollidesWith(this.Collidable)&lt;br /&gt;{&lt;br /&gt;   // change state&lt;br /&gt;   ..&lt;br /&gt;   player.InteractWith(this);&lt;br /&gt;   return true;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;   // collision has stopped&lt;br /&gt;   return false;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;The interactive objects have an internal state, the Update method does different things based on that state. When there is interaction the player gets called with the interactive object so that the player can react to the situation.&lt;br /&gt;&lt;br /&gt;The nice thing about the Tacx virtual trainer is that it can actually generate resistance, and make it harder for you to cycle. We used that in the game as well, if you stay on the road it is quite easy to cycle, and it gets harder if you go off track. when you hit a bug or a rock we increase the resistance exponentially for a short period for extra effect.&lt;br /&gt;&lt;br /&gt;Here are some screenshots from the final result:&lt;br /&gt;&lt;a href=&quot;http://bp2.blogger.com/_8SomWRym6Jg/SHd4trt7qWI/AAAAAAAAAQU/CDw4LR9cCNo/s1600-h/game-3.png&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5221775019184204130&quot; style=&quot;MARGIN: 0px 0px 10px 10px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://bp2.blogger.com/_8SomWRym6Jg/SHd4trt7qWI/AAAAAAAAAQU/CDw4LR9cCNo/s400/game-3.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;In the bottom of the screen is the new CSC logo that you need to complete, by picking up the yellow gems. The bugs will try and interfere with you.&lt;br /&gt;&lt;br /&gt;We put a layer of clouds over all the layers to create a bit of an extra effect. If you fall off the island (by basically riding into the blue tiles) you drown and start over again. (By the way, the score stays zero on these screens cause at the time of creating the screenshots I didn&#39;t have the tacx vr bicycle attached. Riding on the street is easier than riding on the dirtroad, or the grass next to it.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5221774864451607106&quot; style=&quot;MARGIN: 0px 0px 10px 10px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://bp2.blogger.com/_8SomWRym6Jg/SHd4krSzmkI/AAAAAAAAAQM/ncxwLcKnf0g/s400/game-2.png&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;p&gt;You obviously have to try to stay on the road and try not to bump into the rocks and the bugs on the road..&lt;br /&gt;In this case I&#39;m picking up a gem and increasing my score times 8.&lt;/p&gt;&lt;br /&gt;&lt;a href=&quot;http://bp2.blogger.com/_8SomWRym6Jg/SHd42TsY6ZI/AAAAAAAAAQc/yZCkKNqJdAY/s1600-h/game-4.png&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5221775167354104210&quot; style=&quot;MARGIN: 0px 0px 10px 10px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://bp2.blogger.com/_8SomWRym6Jg/SHd42TsY6ZI/AAAAAAAAAQc/yZCkKNqJdAY/s400/game-4.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;As you can see you can zoom out while you are playing (with the controls on the handle bar of the bicycle) to help find the gems on the island. Once you have picked up enough gems to complete the logo, the Logo zooms in to the middle of the screen and you can fill in your name on the high-scores.&lt;/p&gt;&lt;a href=&quot;http://bp1.blogger.com/_8SomWRym6Jg/SHd4U7x54KI/AAAAAAAAAQE/m0BEm3_hc1k/s1600-h/game-1.png&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5221774593999102114&quot; style=&quot;MARGIN: 0px 0px 10px 10px; CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://bp1.blogger.com/_8SomWRym6Jg/SHd4U7x54KI/AAAAAAAAAQE/m0BEm3_hc1k/s400/game-1.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;</description><link>http://roestenburg.agilesquad.com/2008/07/simple-xna-game.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://bp1.blogger.com/_8SomWRym6Jg/SHd3xJKoSAI/AAAAAAAAAP0/vkA3EQdWcrw/s72-c/trainers_245x340.jpg" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-8422476245550579734</guid><pubDate>Sun, 01 Jun 2008 18:33:00 +0000</pubDate><atom:updated>2008-06-01T22:08:56.225+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SOA</category><title>No WOW for WOA</title><description>I was at an architect community meeting when I first heard of the term WOA, and later looked up some references on the internet. I am not sure who coined the term and why. WOA stands for Web Oriented Architecture. The first couple of questions that came to mind were &quot;Sounds like SOA, what&#39;s the difference?&quot; and &quot;Do we really need another acronym?&quot;. After googling a bit (for instance http://www.ddj.com/web-development/207600577) I found the following:&lt;br /&gt;&quot;Web-Oriented Architecture is an alternative to Service-Oriented Architecture. WOA is fundamentally about &quot;open&quot; systems that communicate over &quot;open&quot; and established protocols and formats.&quot;&lt;br /&gt;Hm. SOA uses open formats, and services are open, use of established protocols and formats are fine as well. Why is WOA an &quot;alternative&quot;?&lt;br /&gt;&lt;br /&gt;&quot;In WOA, HTTP takes center-stage as the communication protocol between applications and web-services. Beyond that, the exchange format is also web-centric and is often XHTML, RSS, RDF, or other such formats.&quot;&lt;br /&gt;&lt;br /&gt;Hm. Ok fine. you can have a SOA with HTTP on the center stage. You could have CORBA for that matter. SOA does not say that HTTP is excluded from the protocols it can work with. SOA does not say that RSS is not allowed or something like that. &lt;br /&gt;&lt;br /&gt;Maybe a good time to try and explain what I understand as SOA. At this point I was almost going to try and write it down, but instead of repeating what is already on the web, I&#39;ll just refer you to the OASIS reference model of SOA: http://www.oasis-open.org/committees/download.php/18486/pr-2changes.pdf.&lt;br /&gt;&lt;br /&gt;By the way, RSS is actually a very good example of a service implementation if you look at the OASIS paper of what a service is.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&quot;In WOA, web-services embrace the same technological design principles that web-applications have been following for years: communication between services is stateless, formats are open and extensible, and data exchanges are cacheable. All desirable properties for creating large scale, ad-hoc networks of connected, heterogenous web-services. &quot;&lt;br /&gt;&lt;br /&gt;That just sounds like really good things to do when you design services. No difference again here with SOA. SOA says nothing about not-caching, statefull, closed formats, not-extensible. A lot of the articles floating around try to make a connection between SOA and SOAP. Although there is alot implemented today with SOAP, this is not a prerequisite for SOA.&lt;br /&gt;&lt;br /&gt;Then I read the following:&lt;br /&gt;http://weblog.infoworld.com/realworldsoa/archives/2008/04/why_woasoa_is_m.html&lt;br /&gt;&lt;br /&gt;&quot;SOA should extend out of the firewall to the Internet, if you&#39;re to provide real value to your enterprise. However, this was not universally accepted by the rank-and-file SOA guys. Indeed, generally speaking most viewed SOA as something that occurred within the firewall exclusively, and extending the reach of their SOA to Internet-based resources was taboo.&quot;&lt;br /&gt;&lt;br /&gt;That is opinion, not definition. How you do your security is implementation detail. (Obviously you will have far different requirements in a SOA environment)&lt;br /&gt;From the OASIS reference model:&lt;br /&gt;&lt;br /&gt;&quot;Service Oriented Architecture (SOA) is a paradigm for organizing and utilizing distributed capabilities that may be under the control of different ownership domains.&quot;&lt;br /&gt;&lt;br /&gt;Sounds like cross firewall to me.&lt;br /&gt;&lt;br /&gt;&quot;Not sure if anyone is selling this as a replacement to SOA, or traditional enterprise architecture, but it&#39;s really an approach to architecture where there is a core acceptance that Web-based resources may provide the most speed to delivery, the largest number of resources, and with minimum amount cost. That&#39;s it.&quot;&lt;br /&gt;&lt;br /&gt;And in my opinion, all of that is a narrowing down of a specific implementation of a service oriented architecture style that doesnt really add more meaning, at least not enough for me to start using the term.</description><link>http://roestenburg.agilesquad.com/2008/06/no-wow-for-woa.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1353705672307703652.post-2500874521364010582</guid><pubDate>Fri, 23 Nov 2007 10:16:00 +0000</pubDate><atom:updated>2007-12-01T17:13:15.867+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Dependency Injection</category><category domain="http://www.blogger.com/atom/ns#">Spring.NET</category><category domain="http://www.blogger.com/atom/ns#">WCF</category><title>Configure WCF service dependency injection using Spring.NET</title><description>I am a big fan of Spring, Spring.NET and Dependency Injection, specifically DI that can be done transparantly to the objects it configures.&lt;br /&gt;&lt;br /&gt;I am using Spring.NET dependency injection in my WCF services as described by Oran Dennison:&lt;br /&gt;&lt;a href=&quot;http://orand.blogspot.com/2006/10/wcf-service-dependency-injection.html&quot;&gt;http://orand.blogspot.com/2006/10/wcf-service-dependency-injection.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I only didn&#39;t like to &#39;take the ServiceHost route&#39; that Oran took, and found out it is quite easy to &#39;take the configuration route&#39;:&lt;br /&gt;&lt;p/&gt;&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;xml&quot;&gt;&lt;br /&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;  &amp;lt;!-- Put the necessary Spring.NET config here&lt;br /&gt;  --&amp;gt; &lt;br /&gt;  &amp;lt;system.serviceModel&amp;gt;&lt;br /&gt;    &amp;lt;services&amp;gt;&lt;br /&gt;      &amp;lt;service behaviorConfiguration=&quot;InjectionBehavior&quot;&lt;br /&gt;               name=&quot;AgileSquad.Service.MyService&quot;&amp;gt;&lt;br /&gt;        &amp;lt;endpoint address=&quot;http://localhost/MyService&quot;&lt;br /&gt;                  binding=&quot;basicHttpBinding&quot;&lt;br /&gt;                  name=&quot;basicProfileBinding&quot;&lt;br /&gt;                  contract=&quot;AgileSquad.Service.IMyServiceInterface&quot; /&amp;gt;&lt;br /&gt;      &amp;lt;/service&amp;gt;&lt;br /&gt;    &amp;lt;/services&amp;gt;&lt;br /&gt;    &amp;lt;behaviors&amp;gt;&lt;br /&gt;      &amp;lt;serviceBehaviors&amp;gt;&lt;br /&gt;        &amp;lt;behavior name=&quot;InjectionBehavior&quot;&amp;gt;&lt;br /&gt;          &amp;lt;springBehavior/&amp;gt;&lt;br /&gt;        &amp;lt;/behavior&amp;gt;&lt;br /&gt;      &amp;lt;/serviceBehaviors&amp;gt;&lt;br /&gt;    &amp;lt;/behaviors&amp;gt;&lt;br /&gt;    &amp;lt;!-- Behavior extensions --&amp;gt;&lt;br /&gt;    &amp;lt;extensions&amp;gt;&lt;br /&gt;      &amp;lt;behaviorextensions&amp;gt;&lt;br /&gt;        &amp;lt;!-- springBehavior extension&lt;br /&gt;             for injecting using Spring using&lt;br /&gt;             custom WCF InstanceProvider&lt;br /&gt;        --&amp;gt;&lt;br /&gt;        &amp;lt;add name=&quot;springBehavior&quot;&lt;br /&gt;             type=&quot;AgileSquad.Wcf.SpringServiceBehavior,AgileSquad.Wcf,&lt;br /&gt;             Version=1.0.0.0, Culture=neutral, PublicKeyToken=mykeytoken&quot;/&amp;gt;&lt;br /&gt;        &amp;lt;/behaviorextensions&amp;gt;&lt;br /&gt;    &amp;lt;/extensions&amp;gt;&lt;br /&gt;  &amp;lt;/system.serviceModel&amp;gt;&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p/&gt;&lt;br /&gt;The &lt;em&gt;behaviorConfiguration&lt;/em&gt; attribute on the &lt;em&gt;service&lt;/em&gt; element points to a &lt;em&gt;behavior&lt;/em&gt; configuration, &lt;br /&gt;found in the &lt;em&gt;behaviors&lt;/em&gt; element.&lt;br /&gt;You add your own behavior extension through WCF&#39;s &lt;em&gt;extensions&lt;/em&gt; mechanism. My service behavior implementation is strongly named, so replace the &lt;em&gt;PublicKeyToken&lt;/em&gt; with a real keytoken instead of &#39;mykeytoken&#39;, and obviously you would still have to add your Spring.NET configuration as described in Oran&#39;s post.</description><link>http://roestenburg.agilesquad.com/2007/11/configuring-wcf-service-dependency.html</link><author>noreply@blogger.com (Raymond Roestenburg)</author><thr:total>3</thr:total></item></channel></rss>