You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2012/06/17 14:24:34 UTC

svn commit: r1351096 - in /servicemix/smx4/features/trunk/examples: ./ akka/ akka/akka-camel/ akka/akka-camel/src/ akka/akka-camel/src/main/ akka/akka-camel/src/main/resources/ akka/akka-camel/src/main/resources/OSGI-INF/ akka/akka-camel/src/main/resou...

Author: gertv
Date: Sun Jun 17 12:24:32 2012
New Revision: 1351096

URL: http://svn.apache.org/viewvc?rev=1351096&view=rev
Log:
SMX4-1186: Add an example for using akka-camel

Added:
    servicemix/smx4/features/trunk/examples/akka/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/README.txt
    servicemix/smx4/features/trunk/examples/akka/akka-camel/pom.xml
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/OSGI-INF/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/OSGI-INF/blueprint/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/OSGI-INF/blueprint/akka-camel.xml
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/application.conf
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Application.scala
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/CamelBridge.scala
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/RouteBuilder.scala
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Stats.scala
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/generate_test_data.rb   (with props)
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/log4j.properties
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file1.csv
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file2.csv
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file3.csv
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file4.csv
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file5.csv
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/RouteBuilderTest.scala
    servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala
    servicemix/smx4/features/trunk/examples/akka/pom.xml
      - copied, changed from r1350428, servicemix/smx4/features/trunk/examples/pom.xml
Modified:
    servicemix/smx4/features/trunk/examples/pom.xml

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/README.txt
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/README.txt?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/README.txt (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/README.txt Sun Jun 17 12:24:32 2012
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Akka and Camel Example
+======================
+
+Purpose
+-------
+This example will show you how to use Akka inside Apache ServiceMix and how
+interact with your Akka actors from within you Camel routes.
+
+Our example contains a route that copies files with scores for countries from
+one directory to the other.  It also wiretaps this information into a statistics
+actor, which will do some number-crunching to calculate some basic descriptive
+statistics about these scores.  Once every 30 seconds, a summary report will be
+generated with the statistical summary per country.
+
+Explanation
+-----------
+In the Blueprint XML file (akka-camel.xml), we are:
+1. setting up the Akka actor system, using the <akka:actor-system/> element
+2. creating our Camel route builder bean
+3. bootstrapping our application, using the actor system and route builder we
+   defined in 1. and 2.
+
+The Camel route builder defines two distinct routes:
+1. The first route will process files in var/akka-camel/input directory and
+   move them to the var/akka-camel/output directory.  It will also send a copy
+   of the file contents to the 'direct:stats' endpoint for Akka to work with.
+2. The second route will receive messages from the 'direct:reports' endpoint
+   and write those message to files in the var/akka/reports directory
+
+And finally, we have a set of actors calculating descriptive statistics and two
+additional actors to bridge between the statistics system and the Camel routes:
+1. One of these actors acts as a consumer and receives messages on the 'direct:stats'
+   endpoint to send them into the statistics actor.
+2. The other actor acts as a producer and is set up to regularly (every 30 seconds)
+   send a summary report to the 'direct:reports' endpoint.
+   
+Prerequisites for Running the Example
+-------------------------------------
+1. You must have the following installed on your machine:
+
+   - JDK 1.6 or higher
+
+   - Maven 3.0.2 or higher (for building)
+   
+  For more information, see the README in the top-level examples
+  directory.
+
+2. Start ServiceMix by running the following command:
+
+    <servicemix_home>/bin/servicemix          (on UNIX)
+    <servicemix_home>\bin\servicemix          (on Windows)
+
+
+Running the Example
+-------------------
+To install and run the example where you build the example bundle
+yourself, complete the following steps:
+
+1. Before being able to run this example, you have to install some additional
+   features into the container first to add support for the Camel Scala DSL and
+   for Akka itself.
+
+     features:install camel-scala
+     features:install akka
+
+2. Build the example by opening a command prompt, changing directory to
+   examples/akka/akka-camel (this example) and entering the following Maven
+   command:
+
+     mvn clean install
+   
+   If all of the required OSGi bundles are available in your local Maven
+   repository, the example will build very quickly. Otherwise it may
+   take some time for Maven to download everything it needs.
+   
+   The mvn install command builds the example deployment bundle and
+   copies it to your local Maven repository and to the target directory
+   of this example.
+     
+3. Install the example by entering the following command in
+   the ServiceMix console:
+   
+     osgi:install mvn:org.apache.servicemix.examples/akka-camel/${project.version}
+       
+4. Once the bundle has been started, you will see a var/akka-camel/input directory
+   under your ServiceMix installation directory.  There are some sample files available
+   in this example's src/test/resources/samples directory.  If you copy these files
+   to the input directory mentioned before, they will be moved to var/akka-camel/output
+   directory.
+
+5. After a short while, you will also see summary reports appearing in the var/akka-camel/reports
+   directory, containing the score count, average and standard deviation per country.  These
+   calculations are being doing asynchronously by the Akka actor system.
+
+Stopping and Uninstalling the Example
+-------------------------------------
+First, find the bundle id for the deployed example bundle by doing
+
+  osgi:list
+
+and looking for a line that looks like this one
+
+  [ 263] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Examples :: Akka :: Akka Camel (${project.version})
+
+In the above case, the bundle id would be 263
+
+
+To stop the example, enter the following command in the ServiceMix
+console:
+
+  osgi:stop <bundle_id>
+
+
+To uninstall the example, enter one of the following commands in
+the ServiceMix console:
+
+  osgi:uninstall <bundle_id>
\ No newline at end of file

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/pom.xml?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/pom.xml (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/pom.xml Sun Jun 17 12:24:32 2012
@@ -0,0 +1,118 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <parent>
+    <artifactId>akka-examples</artifactId>
+    <groupId>org.apache.servicemix.examples</groupId>
+    <version>4.5.0-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.servicemix.examples</groupId>
+  <artifactId>akka-camel</artifactId>
+  <name>Apache ServiceMix :: Examples :: Akka :: Akka Camel</name>
+  <packaging>bundle</packaging>
+
+  <properties>
+    <akka.version>2.1-SNAPSHOT</akka.version>
+    <maven-scala-plugin.version>2.15.2</maven-scala-plugin.version>
+    <scala.version>2.9.1</scala.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.scala-lang</groupId>
+      <artifactId>scala-library</artifactId>
+      <version>${scala.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.typesafe.akka</groupId>
+      <artifactId>akka-actor</artifactId>
+      <version>${akka.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.typesafe.akka</groupId>
+      <artifactId>akka-osgi</artifactId>
+      <version>2.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>com.typesafe.akka</groupId>
+      <artifactId>akka-camel</artifactId>
+      <version>2.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-scala</artifactId>
+      <version>${camel.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <version>${camel.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <repositories>
+    <repository>
+      <id>akka.releases</id>
+      <url>http://repo.akka.io/releases</url>
+      <name>Akka Release Repository</name>
+      <releases>
+        <enabled>true</enabled>
+      </releases>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
+
+  <build>
+    <sourceDirectory>src/main/scala</sourceDirectory>
+    <testSourceDirectory>src/test/scala</testSourceDirectory>
+    <plugins>
+      <plugin>
+        <groupId>org.scala-tools</groupId>
+        <artifactId>maven-scala-plugin</artifactId>
+        <version>${maven-scala-plugin.version}</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>compile</goal>
+              <goal>testCompile</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <scalaVersion>${scala.version}</scalaVersion>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+            <Bundle-Description>${project.description}</Bundle-Description>
+            <Import-Package>akka.osgi.blueprint,org.osgi.framework,akka.event,*</Import-Package>
+            <Export-Package>org.apache.servicemix.examples.akka</Export-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/OSGI-INF/blueprint/akka-camel.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/OSGI-INF/blueprint/akka-camel.xml?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/OSGI-INF/blueprint/akka-camel.xml (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/OSGI-INF/blueprint/akka-camel.xml Sun Jun 17 12:24:32 2012
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:akka="http://akka.io/xmlns/blueprint/v1.0.0">
+
+  <!--
+    The <akka:actor-system/> will create and start the Akka actor system
+  -->
+  <akka:actor-system id="system" name="AkkaCamelExample" />
+
+  <!--
+    Our Camel RouteBuilder implementation
+  -->
+  <bean id="routes" class="org.apache.servicemix.examples.akka.RouteBuilderImpl" />
+
+  <!--
+    With the static factory method Application#apply(ActorSystem, RouteBuilder), we will
+    bootstrap our own applications - this method will start the statistics actors and
+    it will also create and start our CamelContext with our routes.
+  -->
+  <bean class="org.apache.servicemix.examples.akka.Application" factory-method="apply">
+    <argument ref="system" />
+    <argument ref="routes" />
+  </bean>
+
+</blueprint>

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/application.conf
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/application.conf?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/application.conf (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/resources/application.conf Sun Jun 17 12:24:32 2012
@@ -0,0 +1,5 @@
+akka.actor.deployment {
+  # there's no extra configuration here at the moment, but you could
+  # configure routers, log levels, ... or whatever settings you need
+  # for your own application
+}
\ No newline at end of file

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Application.scala
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Application.scala?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Application.scala (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Application.scala Sun Jun 17 12:24:32 2012
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.examples.akka
+
+import akka.actor.ActorSystem
+import org.apache.camel.scala.dsl.builder.{RouteBuilder, RouteBuilderSupport}
+
+/**
+ * Application bootstrap class.  This class will start the necessary actors on
+ * the actor system to
+ */
+object Application extends RouteBuilderSupport {
+
+  def apply(system: ActorSystem, builder: RouteBuilder) = {
+    val stats = Stats(system)
+    val camel = CamelBridge(system, stats)
+
+    camel.context.addRoutes(builder)
+    stats
+  }
+
+}

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/CamelBridge.scala
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/CamelBridge.scala?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/CamelBridge.scala (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/CamelBridge.scala Sun Jun 17 12:24:32 2012
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.examples.akka
+
+import akka.actor.{Props, Actor, ActorRef, ActorSystem}
+import akka.camel._
+import io.Source
+import org.apache.servicemix.examples.akka.Stats.{Input, Report}
+import akka.util.duration._
+
+/**
+ * Sets up the actors that bridge between the Camel routes and the
+ * Akka actors.
+ */
+object CamelBridge {
+
+  val STATS_ENDPOINT = "direct:stats"
+  val REPORTS_ENDPOINT = "direct:reports"
+
+  def apply(system: ActorSystem, stats: ActorRef) = {
+    val camel = CamelExtension(system)
+    system.actorOf(Props(new CamelConsumer(stats)), "camel.consumer")
+
+    val producer = system.actorOf(Props[CamelProducer])
+    system.scheduler.schedule(5 seconds, 30 seconds) {
+      stats.tell(Report(), producer)
+    }
+
+    camel
+  }
+
+}
+
+/**
+ * This akka-camel consumer endpoint will receive messages from the endpointUri and
+ * sends the data for each line in the String body that corresponds to <key>,<integer>
+ * to the stats actor
+ *
+ * @param stats the stats engine entry actor
+ */
+class CamelConsumer(val stats: ActorRef) extends Actor with Consumer {
+
+  def endpointUri = "direct:stats"
+
+  def receive = {
+    case CamelMessage(body: String, _) => Source.fromString(body).getLines().foreach(line =>
+      line.split(",") match {
+        case Array(key, value) => try {
+          stats ! Input(key, value.toInt)
+        } catch {
+          case e: NumberFormatException => //second element is not a number, skipping stats for it
+        }
+      }
+    )
+  }
+}
+
+/**
+ * This is an akka-camel producer endpoint.  Message being received by this endpoint will be forwarded
+ * to the endpointUri defined.
+ */
+class CamelProducer extends Actor with Producer with Oneway {
+
+  def endpointUri = CamelBridge.REPORTS_ENDPOINT
+
+}

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/RouteBuilder.scala
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/RouteBuilder.scala?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/RouteBuilder.scala (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/RouteBuilder.scala Sun Jun 17 12:24:32 2012
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.examples.akka
+
+import org.apache.camel.scala.dsl.builder.RouteBuilder
+import org.apache.camel.Exchange
+import CamelBridge.{REPORTS_ENDPOINT, STATS_ENDPOINT}
+
+/**
+ * Abstract RouteBuilder implementation with the basic route definitions,
+ * but with placeholders for the endpoints to be used to allow for testing.
+ */
+abstract class AbstractRouteBuilder extends RouteBuilder {
+
+  def start: String
+  def end: String
+  def reports: String
+
+  start ==> {
+    wireTap(STATS_ENDPOINT, exchange => exchange.getIn.getBody(classOf[String]))
+    to(end)
+  }
+
+  REPORTS_ENDPOINT ==> {
+    setHeader(Exchange.FILE_NAME, simple("summary-${date:now:yyyyMMdd-HHmmss}.txt"))
+    to(reports)
+  }
+}
+
+/**
+ * Runtime endpoint definitions for our route builder
+ */
+class RouteBuilderImpl extends AbstractRouteBuilder {
+
+  def start   = "file:var/akka-camel/input"
+  def end     = "file:var/akka-camel/output"
+
+  def reports = "file:var/akka-camel/reports"
+
+}

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Stats.scala
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Stats.scala?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Stats.scala (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Stats.scala Sun Jun 17 12:24:32 2012
@@ -0,0 +1,134 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.examples.akka
+
+import akka.actor.{ActorRef, Actor, Props, ActorSystem}
+import akka.pattern._
+import akka.util.Timeout
+import akka.util.duration._
+import collection.mutable.Map
+import collection.SortedSet
+import org.apache.servicemix.examples.akka.Stats.Metric
+import java.util.concurrent.atomic.AtomicBoolean
+
+
+/**
+ * A statistics engine that generates basic descriptive statistics (count, average and standard deviation) for a
+ * stream of key,value pairs.  Use Stats(<ActorSystem>) to start the engine and return an actor that you can interact
+ * with using these two messages:
+ * - Input(key, value) to submit another value for calculation
+ * - Report() to request an overall report for all scores
+ */
+object Stats {
+
+  case class Report()
+  case class Input(val key: String, val value: Int)
+  case class Metric[T](val metric: String, val key: String, val result: T)
+
+  def apply(system: ActorSystem) : ActorRef = system.actorOf(Props[Stats], name = "stats")
+
+}
+
+class Stats extends Actor {
+
+  import Stats._
+
+  val average = context.actorOf(Props[Average], "average")
+  val stddev = context.actorOf(Props(new StdDev(average)), "stddev")
+  val batcher = context.actorOf(Props(new Batcher(Seq(average, stddev))), "batcher")
+
+  val metrics = Map.empty[String, Map[String, Any]].withDefaultValue(Map.empty[String, Any])
+  val changes = new AtomicBoolean(false)
+
+  def receive = {
+    case Input(key, value) => batcher ! (key, value);
+    case Metric(metric, key, result) => {
+      metrics(key) = metrics(key) + (metric -> result)
+      changes.set(true)
+    }
+    case Report() => {
+      if (changes.getAndSet(false)) {
+        val results = SortedSet(metrics.keys.toArray:_*).map { key =>
+          val results = metrics(key)
+          "%s,%d,%.4f,%.4f".format(key, results.getOrElse("count", 0),
+                                   results.getOrElse("avg", Double.NaN),
+                                   results.getOrElse("stddev", Double.NaN))
+        }
+        sender ! ("key,count,average,stddev" +: results.toSeq).mkString(sys.props("line.separator"))
+      }
+    }
+  }
+
+}
+
+class Batcher(val stats: Seq[ActorRef]) extends Actor {
+
+  val batches = Map.empty[String, Seq[Int]].withDefaultValue(Seq())
+
+  def receive = {
+    case (key: String, value: Int) => {
+      val batch = value +: batches(key)
+      batches(key) = batch
+      for (stat <- stats) stat.tell((key, batch), sender)
+      sender ! Metric("count", key, batch.size)
+    }
+  }
+
+}
+
+class Average extends Actor {
+
+  def receive = {
+    case (key: String, items: Seq[Int]) => sender ! Metric("avg", key, avg(items))
+    case items: Seq[Int] => sender ! avg(items)
+  }
+
+
+  def avg(items: scala.Seq[Int]): Double = {
+    items.foldLeft(0)(_ + _).toDouble / items.size
+  }
+}
+
+class StdDev(val average: ActorRef) extends Actor {
+
+  val sum_of_squares = context.actorOf(Props[SumOfSquares], "sum_of_squares")
+
+  implicit val timeout = Timeout(1 seconds)
+
+  def receive = {
+    case (key: String, items: Seq[Int]) if items.size > 1 =>
+      val original = sender
+      ask(average, items).onSuccess {
+        case avg : Double => {
+          ask(sum_of_squares, (items, avg)).onSuccess {
+            case ss : Double => {
+              original ! Metric("stddev", key, math.sqrt(ss / items.size - 1))
+            }
+          }
+        }
+      }
+    }
+}
+
+class SumOfSquares extends Actor {
+
+  def receive = {
+    case (items: Seq[Int], avg: Double) =>
+      sender ! items.map(item => math.pow(item.toDouble - avg, 2)).foldLeft(0d)(_ + _)
+  }
+
+}
\ No newline at end of file

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/generate_test_data.rb
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/generate_test_data.rb?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/generate_test_data.rb (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/generate_test_data.rb Sun Jun 17 12:24:32 2012
@@ -0,0 +1,10 @@
+#!/usr/bin/ruby
+
+countries = ['AUS', 'BEL', 'CAN', 'CHN', 'FRA', 'GBR', 'GER', 'GRC', 'GRL', 
+             'IRL', 'NLD', 'NOR', 'SJM', 'SWE', 'TTO', 'TZA', 'USA', 'ZMB']
+
+200.times { 
+  country = countries[rand(countries.length)]
+  score = 1 + rand(1000)
+  puts "#{country},#{score}"
+}

Propchange: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/generate_test_data.rb
------------------------------------------------------------------------------
    svn:executable = *

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/log4j.properties?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/log4j.properties (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/log4j.properties Sun Jun 17 12:24:32 2012
@@ -0,0 +1,33 @@
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You under the Apache License, Version 2.0
+#    (the "License"); you may not use this file except in compliance with
+#    the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, out
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/akka-camel.log
+log4j.appender.out.append=true

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file1.csv
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file1.csv?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file1.csv (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file1.csv Sun Jun 17 12:24:32 2012
@@ -0,0 +1,200 @@
+BEL,911
+TT0,934
+BEL,496
+GRL,228
+GRL,515
+TT0,664
+TT0,578
+GBR,488
+AUS,686
+GRC,943
+TT0,980
+GRL,458
+CHN,735
+SWE,939
+USA,984
+CHN,671
+CAN,435
+ZMB,693
+GBR,77
+NLD,279
+AUS,232
+USA,857
+GBR,161
+GBR,950
+ZMB,560
+IRL,682
+TZA,949
+IRL,100
+CHN,610
+BEL,274
+GER,64
+USA,938
+FRA,288
+IRL,231
+USA,292
+IRL,343
+SJM,55
+GRC,31
+TT0,69
+GER,472
+CAN,312
+CHN,789
+GER,498
+USA,339
+FRA,830
+GBR,101
+AUS,276
+CAN,242
+FRA,321
+CHN,772
+USA,309
+CAN,302
+GBR,82
+GBR,349
+USA,83
+CHN,965
+IRL,961
+GRL,523
+SWE,232
+GRL,706
+AUS,581
+IRL,942
+NOR,299
+CHN,458
+GBR,86
+ZMB,123
+ZMB,101
+GBR,654
+IRL,229
+TT0,172
+GER,841
+SWE,892
+CAN,668
+TT0,213
+CAN,42
+FRA,710
+USA,270
+GER,59
+CAN,680
+TZA,313
+ZMB,581
+SJM,143
+FRA,661
+NOR,152
+SWE,101
+TZA,595
+GRL,390
+AUS,788
+GBR,27
+NLD,968
+TT0,711
+SWE,731
+CAN,758
+BEL,727
+TZA,94
+SJM,743
+SWE,254
+BEL,256
+IRL,912
+NLD,386
+CHN,802
+CAN,310
+BEL,725
+CAN,231
+GER,377
+GRC,379
+GBR,677
+IRL,178
+NOR,629
+TZA,505
+SWE,580
+USA,617
+NOR,604
+AUS,994
+NLD,124
+TT0,908
+BEL,432
+NOR,660
+SJM,446
+GRL,249
+FRA,167
+CHN,261
+GRL,644
+BEL,534
+GBR,622
+FRA,144
+NOR,677
+NOR,916
+NOR,724
+ZMB,807
+CAN,282
+TT0,227
+GRL,178
+NLD,612
+IRL,108
+CHN,664
+CAN,530
+TT0,344
+USA,756
+USA,502
+IRL,472
+GRC,651
+GRC,589
+USA,648
+IRL,326
+IRL,493
+AUS,941
+CAN,55
+NOR,415
+NOR,97
+TZA,69
+CHN,124
+AUS,881
+GER,239
+CAN,380
+CHN,416
+NOR,739
+NOR,921
+ZMB,917
+BEL,504
+TZA,280
+BEL,394
+GRL,233
+SWE,105
+GRL,823
+SWE,774
+GBR,410
+IRL,970
+GER,550
+IRL,857
+SWE,49
+IRL,406
+BEL,62
+ZMB,373
+FRA,524
+SWE,919
+GRC,462
+GBR,71
+USA,365
+TT0,508
+USA,291
+GER,227
+TT0,869
+CHN,511
+ZMB,651
+TZA,318
+USA,854
+IRL,387
+GRC,249
+SJM,52
+AUS,784
+GER,668
+SWE,632
+AUS,572
+GBR,533
+NOR,625
+BEL,643
+AUS,673
+SJM,958
+USA,215

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file2.csv
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file2.csv?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file2.csv (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file2.csv Sun Jun 17 12:24:32 2012
@@ -0,0 +1,200 @@
+GRL,473
+TT0,491
+IRL,981
+USA,594
+BEL,339
+TT0,504
+NLD,421
+BEL,85
+GRC,410
+IRL,394
+BEL,783
+SWE,551
+TT0,547
+IRL,923
+ZMB,50
+GRC,971
+GRL,343
+ZMB,805
+GBR,809
+ZMB,530
+SJM,894
+IRL,926
+GBR,240
+NOR,244
+IRL,674
+AUS,333
+GRL,907
+BEL,395
+TZA,580
+BEL,186
+GBR,138
+BEL,175
+CHN,676
+TT0,478
+TT0,706
+SWE,218
+CAN,590
+TT0,793
+ZMB,756
+GRC,595
+SWE,303
+SJM,573
+GER,78
+GBR,464
+NLD,369
+TZA,751
+BEL,731
+AUS,910
+SJM,161
+BEL,362
+USA,379
+AUS,227
+SJM,430
+NLD,181
+TT0,514
+SJM,93
+GRC,418
+GRL,901
+GRC,342
+TZA,101
+GRL,825
+FRA,580
+IRL,90
+GER,250
+CAN,278
+CAN,489
+GER,388
+IRL,5
+GBR,898
+BEL,399
+ZMB,233
+CAN,872
+BEL,618
+IRL,719
+TZA,385
+SJM,260
+TZA,729
+SJM,394
+GER,973
+TZA,118
+CAN,271
+AUS,302
+GRC,45
+CAN,961
+SWE,627
+SWE,623
+GRC,569
+GRC,188
+SJM,38
+BEL,907
+AUS,592
+TT0,388
+SJM,984
+GRL,722
+BEL,216
+IRL,845
+CAN,665
+TT0,746
+GRC,319
+TZA,119
+CHN,734
+CAN,929
+CHN,626
+TZA,275
+GER,982
+CAN,957
+CHN,13
+SJM,656
+FRA,807
+TZA,134
+FRA,673
+CAN,995
+NOR,470
+TT0,72
+NOR,387
+CHN,769
+NOR,977
+GER,295
+SWE,829
+SWE,283
+FRA,60
+NOR,635
+SWE,278
+CHN,269
+USA,292
+CAN,752
+CAN,262
+TZA,276
+SWE,771
+TT0,807
+TT0,178
+NOR,682
+NLD,91
+CHN,394
+GRC,217
+BEL,427
+GRL,509
+NLD,624
+IRL,941
+CAN,213
+SJM,685
+FRA,83
+NOR,757
+GBR,712
+NLD,568
+NLD,816
+NOR,987
+CAN,995
+CAN,914
+FRA,347
+NOR,916
+TT0,156
+USA,267
+CHN,707
+NLD,57
+GRL,875
+NLD,834
+GER,673
+GER,91
+GER,911
+ZMB,207
+TT0,537
+ZMB,984
+IRL,168
+NLD,435
+GBR,658
+CHN,365
+GER,599
+GRL,94
+ZMB,440
+USA,993
+GBR,351
+GRL,64
+GER,213
+IRL,214
+USA,623
+SJM,242
+CAN,644
+SWE,399
+FRA,441
+SJM,943
+GRC,585
+FRA,398
+CHN,220
+BEL,780
+GER,564
+NOR,134
+CAN,466
+SJM,401
+SWE,378
+TT0,33
+GRL,195
+USA,95
+ZMB,958
+CHN,235
+GER,525
+GRL,325
+AUS,100
+GRC,52
+IRL,766

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file3.csv
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file3.csv?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file3.csv (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file3.csv Sun Jun 17 12:24:32 2012
@@ -0,0 +1,200 @@
+FRA,672
+USA,491
+GER,503
+SWE,730
+NLD,242
+ZMB,259
+NOR,565
+GBR,38
+AUS,333
+SWE,922
+USA,983
+IRL,953
+GRC,780
+IRL,446
+GRC,889
+USA,625
+NLD,407
+AUS,1000
+AUS,29
+TT0,715
+SWE,319
+TT0,311
+GER,359
+GER,430
+CAN,814
+CAN,306
+CHN,25
+NOR,159
+FRA,510
+AUS,244
+CAN,344
+AUS,688
+IRL,966
+NOR,988
+SWE,747
+GBR,3
+NOR,752
+IRL,474
+USA,761
+AUS,226
+GRL,877
+SWE,38
+NLD,410
+BEL,250
+SJM,430
+NLD,616
+NLD,695
+FRA,551
+ZMB,35
+CHN,247
+CAN,330
+GBR,265
+GRL,745
+GRL,918
+GBR,947
+NOR,498
+CHN,649
+BEL,456
+GBR,445
+CHN,847
+NLD,238
+CAN,648
+GRL,263
+NLD,419
+GRC,994
+NLD,879
+NOR,271
+TT0,786
+ZMB,159
+GRL,509
+BEL,614
+TZA,610
+TT0,340
+NLD,420
+NLD,166
+NOR,70
+IRL,126
+GRL,843
+GRC,694
+TT0,892
+BEL,351
+GRL,604
+GER,512
+AUS,6
+CAN,277
+GER,401
+SWE,705
+CAN,882
+IRL,817
+NOR,715
+GER,227
+SJM,582
+TZA,963
+GER,913
+CHN,679
+TZA,89
+AUS,587
+TZA,799
+SJM,729
+GBR,325
+USA,377
+FRA,937
+GRC,660
+GER,79
+CHN,302
+SWE,224
+USA,724
+SJM,872
+GRL,466
+BEL,568
+ZMB,850
+GRC,199
+GER,110
+FRA,57
+NLD,543
+CHN,761
+BEL,447
+USA,61
+AUS,175
+ZMB,18
+ZMB,260
+USA,473
+SWE,792
+GRC,722
+TT0,450
+FRA,970
+TZA,470
+SJM,428
+GRC,45
+SJM,733
+GRL,951
+FRA,140
+GRL,849
+USA,397
+ZMB,830
+GBR,942
+TT0,248
+TT0,752
+TZA,224
+CAN,424
+SJM,359
+GRC,322
+GRC,234
+NOR,243
+GBR,625
+CHN,584
+SJM,559
+NOR,887
+CAN,190
+AUS,61
+FRA,536
+USA,219
+CAN,583
+GRC,449
+NOR,236
+CAN,104
+GER,996
+AUS,252
+ZMB,931
+NLD,424
+AUS,786
+SWE,662
+GER,267
+NOR,209
+SJM,919
+TT0,49
+IRL,29
+SWE,84
+GRC,525
+NOR,417
+GRC,716
+SWE,576
+IRL,86
+GBR,525
+GER,332
+GRL,867
+FRA,510
+GBR,558
+GRL,727
+AUS,959
+TT0,248
+TZA,176
+TZA,643
+NOR,432
+FRA,4
+GRC,75
+CAN,821
+NOR,245
+ZMB,839
+GER,210
+SWE,111
+ZMB,879
+NOR,304
+BEL,889
+IRL,127
+ZMB,334
+TT0,829
+GRC,700
+NLD,681
+SWE,381

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file4.csv
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file4.csv?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file4.csv (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file4.csv Sun Jun 17 12:24:32 2012
@@ -0,0 +1,200 @@
+USA,741
+FRA,291
+GBR,383
+AUS,250
+NLD,561
+TT0,70
+GRC,942
+CAN,107
+NLD,618
+ZMB,130
+FRA,927
+GRL,890
+CHN,510
+FRA,966
+GBR,98
+FRA,420
+GBR,573
+USA,396
+CAN,811
+GER,70
+GRL,451
+BEL,75
+TZA,332
+GRC,885
+FRA,983
+TZA,591
+GBR,661
+AUS,658
+BEL,83
+ZMB,82
+NLD,480
+SWE,249
+IRL,576
+NOR,758
+IRL,249
+GRC,714
+IRL,560
+BEL,691
+SWE,778
+SWE,437
+NLD,405
+TZA,697
+SWE,239
+GER,266
+CAN,762
+SWE,692
+IRL,68
+GER,244
+CHN,98
+GER,210
+GRL,960
+IRL,7
+TZA,870
+SWE,635
+USA,90
+NOR,588
+SJM,89
+GRL,399
+NLD,296
+SWE,365
+USA,922
+BEL,774
+GER,540
+NOR,623
+AUS,658
+AUS,980
+NLD,139
+USA,925
+TZA,941
+GER,226
+GER,957
+CAN,889
+NOR,418
+CAN,984
+GRC,885
+TT0,532
+IRL,199
+CHN,153
+IRL,111
+GRC,280
+AUS,1000
+TZA,911
+SJM,974
+FRA,470
+NOR,749
+ZMB,243
+GBR,456
+ZMB,460
+BEL,804
+SWE,567
+GRC,18
+NLD,402
+GBR,942
+ZMB,206
+CHN,977
+ZMB,391
+CHN,692
+ZMB,43
+GRL,571
+CHN,825
+NOR,195
+IRL,257
+GER,648
+AUS,302
+NOR,518
+FRA,310
+CHN,274
+IRL,868
+NLD,802
+GRC,28
+CHN,140
+GRC,949
+USA,261
+FRA,287
+GER,727
+SJM,350
+TT0,239
+TZA,791
+ZMB,78
+SWE,542
+TZA,6
+GER,337
+GBR,819
+GER,997
+USA,89
+SJM,104
+CAN,869
+SWE,637
+GBR,764
+SJM,797
+TZA,71
+ZMB,526
+AUS,111
+GER,997
+SWE,574
+BEL,751
+CAN,905
+GRL,91
+BEL,511
+IRL,338
+CHN,140
+IRL,572
+GRL,297
+GER,64
+TZA,87
+USA,107
+GER,841
+GER,396
+NLD,118
+CAN,619
+CAN,325
+NLD,805
+AUS,309
+CHN,383
+FRA,819
+IRL,89
+NOR,748
+TT0,133
+ZMB,265
+IRL,443
+NOR,677
+FRA,226
+BEL,327
+GRL,808
+SJM,442
+TZA,425
+IRL,678
+USA,218
+USA,812
+TZA,420
+TT0,803
+FRA,766
+GRL,562
+BEL,212
+CAN,163
+IRL,339
+FRA,741
+GRC,677
+FRA,609
+GER,754
+BEL,349
+SJM,186
+SJM,126
+CAN,136
+TZA,729
+GRC,636
+USA,667
+ZMB,650
+USA,686
+GRC,706
+USA,200
+IRL,472
+AUS,971
+SWE,691
+CAN,715
+CHN,399
+SJM,456
+GRC,195
+CAN,793
+USA,832

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file5.csv
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file5.csv?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file5.csv (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/resources/samples/file5.csv Sun Jun 17 12:24:32 2012
@@ -0,0 +1,200 @@
+GRC,360
+NOR,151
+FRA,138
+GBR,559
+AUS,222
+NOR,899
+GER,733
+TZA,535
+GER,214
+TZA,154
+GRC,464
+SWE,426
+IRL,158
+AUS,417
+BEL,848
+SWE,488
+GBR,756
+SWE,677
+NLD,461
+GRL,744
+SWE,399
+BEL,745
+GBR,338
+FRA,635
+GRL,607
+GRL,21
+GER,448
+FRA,938
+ZMB,197
+SWE,391
+GRC,385
+BEL,856
+TZA,678
+ZMB,307
+NLD,132
+SJM,542
+BEL,152
+ZMB,517
+TZA,128
+NOR,354
+SWE,359
+SJM,179
+TZA,136
+NOR,829
+SWE,304
+NOR,670
+GER,634
+NLD,81
+NLD,316
+GER,952
+GER,624
+SWE,62
+IRL,633
+AUS,760
+SWE,753
+TZA,77
+CHN,201
+NLD,469
+SWE,899
+GRL,151
+CHN,108
+BEL,334
+AUS,527
+TZA,118
+ZMB,349
+AUS,868
+TT0,718
+GER,59
+TT0,119
+FRA,118
+CHN,397
+USA,75
+IRL,920
+NLD,180
+USA,535
+NLD,321
+ZMB,157
+BEL,704
+SJM,500
+NLD,233
+FRA,612
+NOR,965
+IRL,13
+CAN,305
+GER,610
+NOR,444
+GRC,865
+ZMB,533
+NLD,621
+TZA,285
+USA,528
+FRA,896
+TZA,734
+GRC,53
+BEL,790
+CAN,399
+GER,414
+TZA,458
+SJM,911
+CHN,466
+CAN,957
+TT0,833
+NOR,404
+FRA,774
+GER,339
+IRL,454
+TZA,83
+BEL,828
+AUS,714
+CHN,727
+GBR,664
+SJM,738
+GRC,58
+GRL,57
+USA,155
+BEL,452
+SWE,299
+FRA,502
+SJM,476
+USA,366
+BEL,451
+CAN,162
+SJM,806
+ZMB,401
+SWE,485
+TT0,377
+CHN,425
+USA,4
+GRC,222
+FRA,417
+BEL,224
+GBR,30
+FRA,853
+GRL,249
+GER,998
+NOR,93
+GBR,476
+IRL,77
+BEL,367
+GER,988
+IRL,244
+SJM,802
+IRL,98
+CHN,60
+SJM,445
+CAN,243
+GER,833
+CHN,823
+GER,241
+NLD,777
+NLD,99
+CHN,184
+GRL,527
+GBR,725
+GER,190
+ZMB,903
+AUS,611
+NLD,285
+SJM,959
+TZA,498
+GER,224
+BEL,243
+NOR,236
+FRA,839
+USA,915
+NOR,561
+BEL,586
+GRC,873
+TZA,254
+NLD,192
+USA,972
+CAN,655
+FRA,452
+CHN,850
+TT0,493
+TZA,540
+CAN,431
+GRL,823
+GRC,69
+GBR,107
+GBR,511
+TT0,565
+CAN,239
+TZA,103
+TZA,824
+AUS,652
+GBR,804
+NLD,330
+TZA,165
+TT0,809
+GRL,733
+ZMB,990
+TZA,371
+GBR,972
+GER,144
+GRL,418
+SWE,144
+SJM,620
+TT0,314
+GBR,963

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/RouteBuilderTest.scala
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/RouteBuilderTest.scala?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/RouteBuilderTest.scala (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/RouteBuilderTest.scala Sun Jun 17 12:24:32 2012
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.examples.akka
+
+import org.apache.camel.test.junit4.CamelTestSupport
+import org.apache.camel.scala.dsl.builder.RouteBuilderSupport
+import akka.actor.ActorSystem
+import org.junit.Test
+import akka.camel.CamelExtension
+
+/**
+ * Test case for the {{AbstractRouteBuilder}}
+ */
+class RouteBuilderTest extends CamelTestSupport with RouteBuilderSupport {
+
+  val MOCK_END = "mock:end"
+  val MOCK_REPORTS = "mock:reports"
+
+  val system = ActorSystem("RouteBuilderTest")
+
+  // let's start the actual application here
+  Application(system, new AbstractRouteBuilder {
+    def start = "file:src/test/resources/samples?noop=true"
+    def end = MOCK_END
+
+    def reports = MOCK_REPORTS
+  })
+
+  @Test
+  def testRoute {
+    // we expect our 5 files to be transferred through the route
+    getMockEndpoint(MOCK_END).expectedMessageCount(5)
+
+    // we expect at least on statistical report within the time required to finish the route
+    getMockEndpoint(MOCK_REPORTS).expectedMinimumMessageCount(1)
+
+    assertMockEndpointsSatisfied()
+  }
+
+  // override this to allow using the CamelTestSupport convenience methods for our akka-camel CamelContext instance
+  override def createCamelContext()= CamelExtension(system).context
+
+}

Added: servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala?rev=1351096&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala (added)
+++ servicemix/smx4/features/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala Sun Jun 17 12:24:32 2012
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.examples.akka
+
+import org.junit.Test
+import org.junit.Assert.fail
+import akka.actor.ActorSystem
+import akka.pattern._
+import akka.util.Timeout
+import akka.util.duration._
+import akka.dispatch.Await
+import org.apache.servicemix.examples.akka.Stats.{Input, Report}
+import java.util.concurrent.TimeoutException
+
+/**
+ * Test case for the stats actor
+ */
+class StatsTest {
+
+  val ITEM1 = "ITEM1"
+  val MAX_ATTEMPTS = 10
+
+  val system = ActorSystem("TestSystem")
+  val stats = Stats(system)
+
+  implicit val timeout = Timeout(100 millis) // needed for `?` below
+
+  @Test
+  def testCountAverageAndStddev() {
+    stats ! Input(ITEM1, 10)
+    stats ! Input(ITEM1, 20)
+
+    // we expect ITEM1's count, average and standard deviation to be in the report
+    expectReport("ITEM1,2,15.0000,4.8990")
+  }
+
+  /*
+   * Wait for report to contain expected output
+   */
+  def expectReport(expectation: String) : Unit = expectReport(expectation, MAX_ATTEMPTS)
+
+  def expectReport(expectation: String, remaining: Int) : Unit = getReport.contains(expectation) match {
+    case true                      => // do nothing here, w received our report
+    case false if (remaining <= 0) => fail("Did not receive reporting containing " + expectation)
+    case false                     => expectReport(expectation, remaining - 1)
+  }
+
+  /*
+   * Get the stats engine report - if no report is available yet, this method will return a blank sheet
+   */
+  def getReport : String = {
+    try {
+      Await.result(stats ? Report(), 100 millis).toString
+    } catch {
+      //Report() only sends back a response if it actually has something to tell
+      case e: TimeoutException => ""
+    }
+  }
+}

Copied: servicemix/smx4/features/trunk/examples/akka/pom.xml (from r1350428, servicemix/smx4/features/trunk/examples/pom.xml)
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/akka/pom.xml?p2=servicemix/smx4/features/trunk/examples/akka/pom.xml&p1=servicemix/smx4/features/trunk/examples/pom.xml&r1=1350428&r2=1351096&rev=1351096&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/pom.xml (original)
+++ servicemix/smx4/features/trunk/examples/akka/pom.xml Sun Jun 17 12:24:32 2012
@@ -22,23 +22,18 @@
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
-        <groupId>org.apache.servicemix</groupId>
-        <artifactId>parent</artifactId>
+        <groupId>org.apache.servicemix.examples</groupId>
+        <artifactId>examples</artifactId>
         <version>4.5.0-SNAPSHOT</version>
-        <relativePath>../parent/pom.xml</relativePath>
     </parent>
 
     <groupId>org.apache.servicemix.examples</groupId>
-    <artifactId>examples</artifactId>
+    <artifactId>akka-examples</artifactId>
     <packaging>pom</packaging>
-    <name>Apache ServiceMix :: Features :: Examples</name>
+    <name>Apache ServiceMix :: Examples :: Akka</name>
 
     <modules>
-        <module>activemq</module>
-        <module>camel</module>
-        <module>cxf</module>
-        <module>jbi</module>
-        <module>nmr</module>
+        <module>akka-camel</module>
     </modules>
 
 </project>

Modified: servicemix/smx4/features/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/pom.xml?rev=1351096&r1=1351095&r2=1351096&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/pom.xml (original)
+++ servicemix/smx4/features/trunk/examples/pom.xml Sun Jun 17 12:24:32 2012
@@ -35,6 +35,7 @@
 
     <modules>
         <module>activemq</module>
+        <!-- <module>akka</module>  commented out now until Akka OSGi bundle are available in a repo -->
         <module>camel</module>
         <module>cxf</module>
         <module>jbi</module>