Angel \”Java\” Lopez on Blog

December 14, 2014

Aktores: Implementing Actor Model In C# (2) A Simple Sample

Filed under: .NET, Akka, Aktores, C Sharp, Open Source Projects — ajlopez @ 8:18 am

Previous Post

Let’s review a simple sample that creates two actors, and sends messages to them. The code is at:

https://github.com/ajlopez/Aktores/tree/master/Samples/PingPong

As usual, this is “work in progress”, and could be change in the future. I’m following TDD (Test-Driven Development) workflow, so some API calls could be change when I add new use cases (as distributed samples).

In this solution, we have an actor:

using Aktores.Core;

public class PingActor : Actor
{
    private int messagecount;

    public int MessageCount { get { return this.messagecount; } }

    public override void Receive(object message)
    {
        messagecount++;
        this.Sender.Tell("ping", this.Self);
    }
}

An actor inherits from abtract class Actor. The method to implement is Receive. This method receives a message (sent by other actor, or by other object in the system). Internally, Aktores sends only one message to our instance, we don’t worry about concurrency. The above actor, when receives a message, increments a counters and sends another message to the original sender. This sender is referenced by this.Sender, DURING the process of THIS message. This property can change in the process of another message.

We have another similar actor:

using Aktores.Core;

public class PongActor : Actor
{
    private int messagecount;

    public int MessageCount { get { return this.messagecount; } }

    public override void Receive(object message)
    {
        messagecount++;
        this.Sender.Tell("pong", this.Self);
    }
}

The main program creates an actor systems, creates two actor instances, one of type Ping and the other of type Pong, and sends to them many message to process:

public static void Main(string[] args)
{
    ActorSystem system = new ActorSystem(2);
    var pingactor = new PingActor();
    var pongactor = new PongActor();
    
    var ping = system.ActorOf(pingactor);
    var pong = system.ActorOf(pongactor);

    for (int k = 0; k < 10; k++)
    {
        ping.Tell("pong", pong);
        pong.Tell("ping", ping);
    }

    // ....
}

There is additional code to show the message counters. The parameter 2 in the constructor of ActorSystem indicates the number of internal threads to use to process message. I should review if such info should be specified here. Two threads are enough becase we have only two actor instances, but we could have more actors.

Stay tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

October 9, 2014

Akka: Links, News And Resources (10)

Filed under: Akka, Distributed Computing, Java, Links, Scala — ajlopez @ 4:36 pm

Previous Post

VaughnVernon/Dotsero
https://github.com/VaughnVernon/Dotsero

Distributed Publish Subscribe in Cluster — Akka Documentation
http://doc.akka.io/docs/akka/2.3.2/contrib/distributed-pub-sub.html

Kamon | Core | Documentation
http://kamon.io/core/tracing/core-concepts/

Parleys.com – Resilient Applications with Akka Persistence by Björn Antonsson, Konrad Malawski, Patrik Nordwall
http://www.parleys.com/play/53a7d2c3e4b0543940d9e53b/chapter0/about

AKKA 5 Year Anniversary
http://typesafe.com/akka-five-year-anniversary

How One Developer Set Out To Make The Internet Of Things Manageable – ReadWrite
http://readwrite.com/2014/07/10/akka-jonas-boner-concurrency-distributed-computing-internet-of-things

typesafehub/activator-akka-distributed-workers
https://github.com/typesafehub/activator-akka-distributed-workers/

etaty/rediscala
https://github.com/etaty/rediscala

agibsonccc/java-deeplearning
https://github.com/agibsonccc/java-deeplearning

mpollmeier/akka-patterns
https://github.com/mpollmeier/akka-patterns

Xitrum
http://xitrum-framework.github.io/xitrum/

My Links
http://delicious.com/ajlopez/akka

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

October 6, 2014

Akka: Links, News And Resources (9)

Filed under: Akka, Distributed Computing, Java, Links, Scala — ajlopez @ 4:13 pm

Previous Post
Next Post

Building Reactive Applications with Akka
http://hakking-at.scalabcn.org/

Typed Actors — Akka Documentation
http://doc.akka.io/docs/akka/snapshot/scala/typed-actors.html

Reactive DDD with Akka | Write less, do more!
http://pkaczor.blogspot.co.uk/2014/04/reactive-ddd-with-akka.html

Publish/Subscribe using Scala and Akka EventStream
http://www.benhowell.net/examples/2014/04/18/scala-and-the-akka-eventstream/

Vaadin in Akka – Blog – vaadin.com
https://vaadin.com/blog/-/blogs/vaadin-in-akka

Endre Sándor Varga – Without Present or Past: How to Think Distributed – The Hard Way, With the rise of distributed databases, cluster management tools, co…
http://www.ustream.tv/recorded/46670663

Reactive Programming with Akka and Scala | comSysto Blog
http://blog.comsysto.com/2014/05/09/reactive-programming-with-akka-and-scala/

Let it crash
http://letitcrash.com/

woq/de.woq.osgi.java
https://github.com/woq/de.woq.osgi.java

michaelpisula/akka-journal-inmemory
https://github.com/michaelpisula/akka-journal-inmemory

Jonas Bonér – Going Reactive: Event-Driven, Scalable, Resilient & Responsive Systems, The demands and expectations for applications have changed dramat…
http://www.ustream.tv/recorded/46625425

Get started quicker with our docker image
http://kamon.io/teamblog/2014/04/27/get-started-quicker-with-our-docker-image/

Java is the new C: Comparision of different concurrency models: Actors, CSP, Disruptor and Threads
http://java-is-the-new-c.blogspot.com.ar/2014/01/comparision-of-different-concurrency.html

chanan/SignalJ
https://github.com/chanan/SignalJ

April 17, 2014 | Typesafe announces Akka Streams, a part of the Reactive Streams Initiative | Typesafe
https://typesafe.com/blog/typesafe-announces-akka-streams

akka/akka-stream/src/main/scala/akka/stream at release-2.3 · akka/akka
https://github.com/akka/akka/tree/release-2.3/akka-stream/src/main/scala/akka/stream

A very simple Ping Pong example using Akka’s local actors.
https://gist.github.com/ConnorDoyle/1521658

Orleans Actors Analysis – Tech stuff that interests me
http://shinolajla.tumblr.com/post/81199345476/orleans-actors-analysis

Abstractivate: ForkJoinPool: the Other ExecutorService
http://blog.jessitron.com/2014/02/forkjoinpool-other-executorservice.html

Running an Akka Cluster with Docker Containers | Adventures in HttpContext
http://blog.michaelhamrah.com/2014/03/running-an-akka-cluster-with-docker-containers/

Getting Started with Actor Based Programming Using Scala and Akka – Reactive.TIPS – The Official Blog of Reactive.IO
http://www.reactive.io/tips/2014/03/28/getting-started-with-actor-based-programming-using-scala-and-akka/

My Links
http://delicious.com/ajlopez/akka

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

July 21, 2014

Aktores Implementing Actor Model in C# (1) The Project

Filed under: .NET, Akka, Aktores, C Sharp, Open Source Projects — ajlopez @ 4:11 pm

Next Post

It’s time to write about the project:

https://github.com/ajlopez/Aktores

I’m implementing the first steps towards an actor model, message passing, taking ideas from Akka. I had worked something in Node.js, and C#, having actors sending messages to each other, but this time I want to follow the path of Akka, step by step, for example, have names of actors, in a tree, distributed system of actors, and monitoring agents.

The status of the project today:

The current actor implementation:

First, an Actor is an abstract class, to be implemented in each use case. The rest of the system would not talk to an actor directly, but through a ActorRef. For example, to send a message, there is a method Tell in ActorRef. Internally, no process sends messages to the actor directly, but each actor has a Mailbox. And the mailbox is used by ActorRef to send a message to the final Actor. The Actor object is a passive object: it not manage the Mailbox directly, but there are threads that will take pending tasks, get message from Actor mailbox, and send it to the Actor. The system internally ensures that the actor receives and processes messages one by one. The actor does not have to worry about competition from multiple threads. Notably, the Actor has no direct reference to the Mailbox. More details in upcoming posts.

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

May 13, 2014

Akka: Links, News And Resources (8)

Filed under: Akka, Distributed Computing, Java, Links, Scala — ajlopez @ 10:08 am

Previous Post
Next Post

Streaming Twitter API in Akka and Spray | Cake Solutions Team Blog
http://www.cakesolutions.net/teamblogs/2013/12/08/streaming-twitter-api-in-akka-and-spray/

Akka persistence webinar
http://www.slideshare.net/patriknw/akka-persistence-webinar

Intro to Akka persistence with Patrik Nordwall – YouTube
https://www.youtube.com/watch?v=r5lecCBazvE

Community Page Reinvisioned | Akka
http://akka.io/news/2014/03/12/community-page-update.html

Prabhath’s Bolg: Integrating an Akka.io actor system with Play framework (A distributed message classifier with Akka.io and Play framework)
http://psuminda.blogspot.com.es/2014/02/integrating-akkaio-actor-system-with.html

Martin’s Programming Blog: Distributed Actors in Clojure
http://martinsprogrammingblog.blogspot.com.ar/2012/05/distributed-actors-in-clojure.html

Fun doesn’t mean compromising scalability – all that jazz
http://jazzy.id.au/default/2013/12/17/fun_doesnt_mean_compromising_scalability.html

Using Scala Implicits to Implement a Messaging Protocol
http://derekwyatt.org/2014/01/01/using-scala-implicits-to-implement-a-messaging-protocol.html

Camel — Akka Documentation
http://doc.akka.io/docs/akka/snapshot/scala/camel.html

Post: Akka Extras Email
http://blog.eigengo.com/blog_posts/akka-extras-email

oxlade39/STorrent
https://github.com/oxlade39/STorrent
BitTorrent client written in Scala using Akka

scala – How to create minimal Akka actor? – Stack Overflow
http://stackoverflow.com/questions/17632234/how-to-create-minimal-akka-actor/17638135#17638135

scala/src/library/scala/concurrent/impl/ExecutionContextImpl.scala at master · scala/scala
https://github.com/scala/scala/blob/master/src/library/scala/concurrent/impl/ExecutionContextImpl.scala#L33

My Links
http://delicious.com/ajlopez/akka

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

February 24, 2014

Akka: Links, News And Resources (7)

Filed under: Akka, Distributed Computing, Java, Links, Scala — ajlopez @ 11:11 am

Previous Post
Next Post

ThreadPools
http://www.playframework.com/documentation/2.2.x/ThreadPools

chanan/AkkaGuice
https://github.com/chanan/AkkaGuice

typesafe.com
http://typesafe.com/blog/running-a-2400-akka-nodes-cluster-on-google-compute-engine

Distributed Publish Subscribe in Cluster — Akka Documentation
http://doc.akka.io/docs/akka/2.2.3/contrib/distributed-pub-sub.html

Microkernel — Akka Documentation
http://doc.akka.io/docs/akka/2.2.3/scala/microkernel.html

Typesafe Blog – PlayFramework – Blog – Typesafe
http://typesafe.com/blog/PlayFramework

yngui/akka-disruptor
https://github.com/yngui/akka-disruptor

Dispatchers — Akka Documentation
http://doc.akka.io/docs/akka/snapshot/scala/dispatchers.html

rogeralsing/Pigeon
https://github.com/rogeralsing/Pigeon
Akka in C#

Getting Started Tutorial (Scala): First Chapter — Akka Documentation
http://doc.akka.io/docs/akka/2.0.2/intro/getting-started-first-scala.html

My Links
http://delicious.com/ajlopez/akka

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

February 14, 2014

Akka: Links, News And Resources (6)

Filed under: Akka, Distributed Computing, Java, Links, Scala — ajlopez @ 3:23 pm

Previous Post
Next Post

You know: I’m interested in actor models in general, and Akka implementation in particular, having distributed applications. I started two projects implementing Akka ideas, in Node.js and in C#:

https://github.com/ajlopez/SimpleActors
https://github.com/ajlopez/Aktores

Now, more links of my collection of links:

mrb: Distributed Systems Archaeology: Ricon West, 2013.10.30
http://michaelrbernste.in/2013/11/22/distributed-systems-archaeology.html

Using Akka in Scala IDE – Stack Overflow
http://stackoverflow.com/questions/13585927/using-akka-in-scala-ide

Pacific Northwest Scala 2013 Akka in Production: Our Story by Evan Chan – YouTube
http://www.youtube.com/watch?v=c1heorOM2LE

Akka vs Storm | Blog of Adam Warski | Planet JBoss Community
http://planet.jboss.org/post/akka_vs_storm

Akka in Production: Our Story
http://www.slideshare.net/EvanChan2/akka-inproductionpnw-scala2013

typesafe.com
http://typesafe.com/blog/typesafe-gets-sprayed

Typesafe Reactive Platform Acquires New High-Performance HTTP Foundation
http://www.marketwired.com/press-release/Typesafe-Reactive-Platform-Acquires-New-High-Performance-HTTP-Foundation-1841738.htm

Dev Time: Cope with Failure – Actor Supervision in Akka
http://blog.florian-hopf.de/2013/10/cope-with-failure-actor-supervision-in.html

Akka Work Pulling Pattern to prevent mailbox overflow, throttle and distribute work » Michael on development
http://www.michaelpollmeier.com/akka-work-pulling-pattern/

Going Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
http://www.slideshare.net/jboner/going-reactive-eventdriven-scalable-resilient-systems

Let it crash • Where Akka Came From
http://letitcrash.com/post/40599293211/where-akka-came-from

Typed Channels (EXPERIMENTAL) — Akka Documentation
http://doc.akka.io/docs/akka/2.2.1/scala/typed-channels.html

My Links
http://delicious.com/ajlopez/akka

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

January 15, 2014

End Of Iteration 2014w02

Filed under: .NET, Akka, C Sharp, Iteration, JavaScript, Lambda Calculus, NodeJs — ajlopez @ 6:58 pm

Previous Post
Next Post

A lot of work at the second iteration of the year:

More Code Generation with AjGenesis

I created

https://github.com/ajlopez/AjGenesisNode-Sinatra

with a simple Sinatra site generated using AjGenesis for Node. I should add the entity support (list, persistence, view, edit, new) but it was created in two hours. Nice experience adapting templates

Aktores

An Akka-like actor model implemented in C#. It was born on Sunday:

https://github.com/ajlopez/Aktores

I’m using TDD, as usual. My ideas are implemented using baby steps, make it works, make it right, and in the future, make it fast. I’m not concerned with performance yet, but to have all the pieces in place for local run. Then, I will add distributed processing. One of the key things is the message mailbox management. By now, I have only one by actor system, implemented using a concurrent queue. I planned to add a queue by actor, if specified at creation of the actor.

Scala in JavaScript

The project

https://github.com/ajlopez/ScaScript

An interpreter, not a “transpiler” to JavaScript. I want to do dog fooding of my SimpleGrammar project, and learn a bit about Scala language.

Lambda Calculus

Implemented in JavaScript, a Saturday code kata:

https://github.com/ajlopez/SimpleLambda

Next steps: add named functions.

DylanSharp

More work in my Dylan-like language implemented as an interpreter over C#:

https://github.com/ajlopez/DylanSharp

Others

I added minor functionality to ClojSharp (Clojure-like in C#) https://github.com/ajlopez/ClojSharp/commits/master. I worked on two non-public projects.

More fun is coming

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

October 29, 2013

Akka: Links, News And Resources (5)

Filed under: Akka, Distributed Computing, Links, Sc, Scala — ajlopez @ 6:59 pm

Previous Post
Next Post

spray | Documentation » 1.1-M8 » spray-routing » Advanced Topics » Understanding the DSL Structure
http://spray.io/documentation/1.1-M8/spray-routing/advanced-topics/understanding-dsl-structure/

ktonga/meetup-akka-spray · GitHub
https://github.com/ktonga/meetup-akka-spray
Example from Buenos Aires meetup

Event Bus — Akka Documentation
http://doc.akka.io/docs/akka/snapshot/scala/event-bus.html

Testing Actor Systems — Akka Documentation
http://doc.akka.io/docs/akka/snapshot/scala/testing.html

spray | REST/HTTP for your Akka/Scala Actors
http://spray.io/

「Effective Actors」 Speaker: Jamie Allen(Typesafe) on Vimeo
http://vimeo.com/65556264

How does Cloud Haskell currently compare with Erlang/OTP, Scala/Akka, Clojure/Storm? : haskell
http://www.reddit.com/r/haskell/comments/1ft2l2/how_does_cloud_haskell_currently_compare_with/

Introduction to Actors Systems
http://www.infoq.com/presentations/Akka-Actors

Mile High DDD 2013 by Paul Rayner & Vaughn Vernon
http://milehighddd.com/

Books — Akka Documentation
http://doc.akka.io/docs/akka/2.2-M2/additional/books.html

Play Framework – Build Modern & Scalable Web Apps with Java and Scala
http://www.playframework.com/

Open Source Training – Marakana
http://marakana.com/

Futures in Akka with Scala | Java Code Geeks
http://www.javacodegeeks.com/2013/03/futures-in-akka-with-scala.html

Let it crash • The Second Step: Akka Typed Channels
http://letitcrash.com/post/45188487245/the-second-step-akka-typed-channels

My Links
http://delicious.com/ajlopez/akka

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

October 9, 2013

Akka: Links, News And Resources (4)

Filed under: Akka, Distributed Computing, Links, Scala — ajlopez @ 7:57 pm

Previous Post
Next Post

Introducing Akka – Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Actors ?
http://jonasboner.com/2010/01/04/introducing-akka/

http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf
http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf

The Scala Actors Migration Guide – Scala Documentation
http://docs.scala-lang.org/overviews/core/actors-migration-guide.html

akka/akka-actor/src/main/scala/akka/pattern/AskSupport.scala at master · akka/akka · GitHub
https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/pattern/AskSupport.scala

Akka and CUDA | Javalobby
http://java.dzone.com/articles/akka-and-cuda?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+javalobby/frontpage+(Javalobby+/+Java+Zone)

Actor throttling strategies – Akka User List | Google Groups
https://groups.google.com/group/akka-user/browse_thread/thread/34ffd95414b73be

Could spray have been a wrapper over netty? – Google Groups
https://groups.google.com/forum/#!topic/spray-user/7l1RbqxRuic/discussion

Remoting (Scala) — Akka Documentation
http://doc.akka.io/docs/akka/current/scala/remoting.html

Tutorial: Asynchronous Programming With Akka Actors
http://jaxenter.com/tutorial-asynchronous-programming-with-akka-actors-46220.html

Let it crash • Case Study: An Auto-Updating Cache Using Actors
http://letitcrash.com/post/30509298968/case-study-an-auto-updating-cache-using-actors

Let it crash • Balancing Workload Across Nodes with Akka 2
http://letitcrash.com/post/29044669086/balancing-workload-across-nodes-with-akka-2

jacobgroundwater/federation · GitHub
https://github.com/jacobgroundwater/federation

Federation by jacobgroundwater
http://underflow.ca/federation/

My Links
http://delicious.com/ajlopez/akka

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

Older Posts »

Blog at WordPress.com.