+ All Categories
Home > Engineering > Introduction to akka actors with java 8

Introduction to akka actors with java 8

Date post: 16-Apr-2017
Category:
Upload: johan-andren
View: 6,844 times
Download: 6 times
Share this document with a friend
15
Introduction to Akka Actors with Java 8
Transcript
Page 1: Introduction to akka actors with java 8

Introduction to Akka Actors

with Java 8

Page 2: Introduction to akka actors with java 8

Mememememememememe

Page 3: Introduction to akka actors with java 8

Instead of more Ghz more cores

source: http://queue.acm.org/detail.cfm?id=2181798

Page 4: Introduction to akka actors with java 8

Another thing that has changed

Page 5: Introduction to akka actors with java 8

Build powerful concurrent & distributed applications more easily.

Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM

Page 6: Introduction to akka actors with java 8

”The actor model in computer science is a mathematical model of concurrent computation that treats actors as the universal primitives of concurrent computation. ”

Wikipedia

The Actor Model

Page 7: Introduction to akka actors with java 8

An Actor

and acts on them by: • Sending messages • Changing its state • Changing its behavior • Creating more actors

receives messages

Page 8: Introduction to akka actors with java 8

The Actor hierarchy/user

system.actorOf(props, ”my-actor”)

/user/my-actor

getContext() .actorOf(…, ”my-child”)

/user/my-actor/my-child

Page 9: Introduction to akka actors with java 8

Supervision/user

/user/my-actor

🌋

Page 10: Introduction to akka actors with java 8

Actor Lifecycle

actorOf()

New instance -

restarted

restart

resume

stop

ActorRef

Page 11: Introduction to akka actors with java 8

Dispatch (Actor Execution)Actor-a

Actor-b

Thread 1

Thread 2

b

b

ba a

a

Time

Page 12: Introduction to akka actors with java 8

BlockingActor-a

Actor-b

Thread 1

Thread 2

b b

a

Time

a

Actor-c

Page 13: Introduction to akka actors with java 8

Dos and don’tsDon’t: Put every actor under /userSeparate parts using supervisors so they can fail independently Do: Isolate blocking Put blocking logic on its own thread based dispatcher Don’t: Write all your logic inside your actorsMake what is possible ”regular” OO logic that you can set up and unit test synchronously

Do: Make all messages immutable Or else there will be concurrency/visibility problems

Do: Put asynchronous boundaries where it makes sense Three tier where each tier is an actor is probably not that useful

Page 14: Introduction to akka actors with java 8

What more is there?

Akka Cluster

Akka Streams

and cluster tools

async & back-pressured

Page 15: Introduction to akka actors with java 8

Get startedLearn more - the docs: http://akka.io/docs

Get help: gitter channel: https://gitter.im/akka/akka mailing list: https://groups.google.com/forum/#!forum/akka-user

Project with samples: https://github.com/johanandren/akka-actor-java8-webinar


Recommended