GitXplorerGitXplorer
h

akka-kata-java

public
39 stars
11 forks
0 issues

Commits

List of commits on branch master.
Unverified
ac2de08b5aa584d7e509db573a384775ba0de5d7

Updated readme to link to zip file per default.

hhenrikengstrom committed 12 years ago
Unverified
94637e6e4c97637babb85c5eecb1e83be4684ee0

Merge pull request #3 from patriknw/wip-improvements1

hhenrikengstrom committed 12 years ago
Unverified
9e113ec4037e8ba869f98a166b8c8f05de60fa6c

Some improvements and upgrade to Akka 2.1.2

ppatriknw committed 12 years ago
Unverified
b1b8bfd5b48f6a782c1949c6a4afc726225936c9

Merge pull request #2 from infynyxx/fix_readme

hhenrikengstrom committed 12 years ago
Unverified
7cae3da479ea3a1d7ff9f8617a253734a684578d

Minor README typo fixed

iinfynyxx committed 12 years ago
Unverified
ef9cf58ba9b29ff5181a7971d88d3f5d0ad5d87c

Added link to solution proposal in readme

hhenrikengstrom committed 12 years ago

README

The README file for this repository.

Akka Kata in Java

This repository contains an Akka kata that can be used whenever you feel like doing some Akka Karate related training.

Prerequisites

  • A computer
  • An installed OS
  • Java
  • Maven
  • Git (not mandatory)

Getting Started (Git installed)

So you decided to install Git (or already had it installed). Smart move! Open a terminal and type:

> git clone git://github.com/henrikengstrom/akka-kata-java.git

Getting Started (manually - Git unavailable)

Open a browser and point it to:

https://github.com/henrikengstrom/akka-kata-java/archive/master.zip

Select your preferred flavor of compression (zip or tar.gz), download and extract onto your machine.

Maven

To compile the project with Maven:

> mvn compile

Since it is a multi-module project with dependencies between the modules you need to install the jar files in the local maven repository before running.

> mvn install

Eclipse the project

See Eclipse Guide

IntelliJ the project

Open IntelliJ, select File -> Open Project… and point to the root pom.xml in the project (i.e. the akka-kata-java/pom.xml file).

The Kata ("osu sensei")

The aim with this kata is to show some core elements of Akka:

  • Remoting
  • Supervision
  • Some Akka patterns

To showcase the elements above we have selected to implement a simple betting application - or at least provide a skeleton of such an application. The implemented application should simulate a transacted system, i.e. it should handle a crash of a JVM. We will discuss pros and cons of alternative implementations during the meetup.

The application you create will run in two different JVMs (and actor systems). One "node", called betting service, receives bet messages from a client, creates a transaction number and sends this message to the other "node" betting processor. The betting service keeps track of messages sent and should also handle confirmation messages from the betting processor. It also handles re-sending of messages that have not been confirmed.

The task of the betting processor is to spawn workers that do the dangerous job (in this case interacting with an unstable service), supervise these workers and send back confirmation that a task has been performed.

The betting service should be able to function without any available betting processor, i.e. should it receive bet(s) before the betting processor has registered it should keep these bets locally and send them as soon as a betting processor becomes available.

Sometimes your servers crash(!) and therefore you should design with this in mind. Sending too many bets to the betting processor will cause it (the JVM) to crash. It is an essential part of this kata to make sure that the betting service can handle such a crash.

We will provide some alternative implementations to show how to solve the different tasks/assignments raised in the code (see comments in provided code).

Starting The Parts of the Kata

You should run the service, processor and client in that order to make sure that this kata runs as intended.

Start the service

> cd <project_home>/service
> mvn exec:java -Dexec.mainClass="com.typesafe.akkademo.service.BettingServiceApplication"

The next step is to start the processor

> cd <project_home>/processor
> mvn exec:java -Dexec.mainClass="com.typesafe.akkademo.processor.BettingProcessorApplication"

Finally you should run the client. Start off by sending bets to the service

> cd <project_home>/client
> mvn exec:java -Dexec.mainClass="com.typesafe.akkademo.client.BetClient" -Dexec.args="send"

The final step is to retrieve the bets from the service

> cd <project_home>/client
> mvn exec:java -Dexec.mainClass="com.typesafe.akkademo.client.BetClient"

Remember to clean out the persistent store of bets in between runs of your system. It is stored in the file persistent_store in the top level project directory.

That's it!

Green Belt Akka

For a small collection of akka information useful for this kata see Green Belt Akka

Solution Proposal

When you feel that you have accomplished all tasks specified in the code there is a solution proposal to be found in a branch called solution. We recommend that you try to solve the kata before looking at this proposal though.

Authors