Code Monkey home page Code Monkey logo

akka-kata-java's Introduction

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/downloads

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

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"

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

akka-kata-java's People

Contributors

henrikengstrom avatar infynyxx avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.