Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Typed and UnTyped Actors in Akka? When to use what?

Tags:

java

akka

actor

I have tried to read the Akka documentation to find out the exact difference between Typed and Untyped actors. When to use what? I am not sure what I'm missing. Can somebody point me to something relevant or provide an answer to this question here itself?

like image 853
Kamesh Rao Yeduvakula Avatar asked Nov 15 '11 11:11

Kamesh Rao Yeduvakula


People also ask

What does it mean for an actor to be typed?

In film, television, and theatre, typecasting is the process by which a particular actor becomes strongly identified with a specific character, one or more particular roles, or characters having the same traits or coming from the same social or ethnic groups.

Is akka statically or dynamically Typed?

Akka's actors give you static typing within a single actor, but the communication between actors -- the complex bits that are most likely to go wrong -- are not typed in any useful manner.

Why is akka typed?

Akka Typed is widely praised for bringing compile-time checks to actors and a whole new actor API. The problem is that even this new typed API has loopholes that almost never completely close the old Akka anti-patterns.

What is ActorSystem in akka?

Companion object ActorSystem An actor system is a hierarchical group of actors which share common configuration, e.g. dispatchers, deployments, remote capabilities and addresses. It is also the entry point for creating or looking up actors. There are several possibilities for creating actors (see akka.


3 Answers

UntypedActor is simply the name for Actor but as the Java API.

Here are some links to documentation:

Java:

  • http://akka.io/docs/akka/1.2/java/typed-actors.html
  • http://akka.io/docs/akka/1.2/java/untyped-actors.html

Scala:

  • http://akka.io/docs/akka/1.2/scala/typed-actors.html
  • http://akka.io/docs/akka/1.2/scala/actors.html

The difference is that TypedActors have a static interface, and the invocations of the methods on that interface is transformed into message sends. UntypedActors can receive any message.

Hope that helps.

Cheers, √

like image 61
Viktor Klang Avatar answered Oct 09 '22 09:10

Viktor Klang


Actors (Untyped)

For actors (Scala) to receive messages, they must mixin the Consumer trait. For example, the following actor class (Consumer1) implements the endpointUri method, which is declared in the Consumer trait, in order to receive messages from the file:data/input/actor Camel endpoint. Untyped actors (Java) need to extend the abstract UntypedConsumerActor class and implement the getEndpointUri() and onReceive(Object) methods.

Actors (Typed)

Typed actors can also receive messages from Camel endpoints. In contrast to (untyped) actors, which only implement a single receive or onReceive method, a typed actor may define several (message processing) methods, each of which can receive messages from a different Camel endpoint. For a typed actor method to be exposed as Camel endpoint it must be annotated with the @consume annotation. For example, the following typed consumer actor defines two methods, foo and bar.

Reference

like image 4
Mithun Sasidharan Avatar answered Oct 09 '22 08:10

Mithun Sasidharan


Untyped actors respond to messages sent, while typed actors respond to method calls(the parameter values are the messages).

Typed Actor Model is used in order to define strict contracts for actors that can respond to only the predefined set of messages. In this case, every message need not be encapsulated as one object; typed actors allow us to define separate methods that accept multiple inputs as defined by the contract. In Java parlance, typed actors provide the Java interface in the object-oriented world.[1]

[1] Akka Essentials

like image 2
Sayat Satybald Avatar answered Oct 09 '22 10:10

Sayat Satybald