Is it possible in Akka to create TypedActors with Proxies of more than one interface?

StackOverflow https://stackoverflow.com/questions/8807282

  •  26-10-2019
  •  | 
  •  

문제

Akka Typed actors are created in two parts using JDK proxies, whereby the proxy is a product of a specified interface, and the implementation forms the backing managed instance. However this means of construction prevents a TypedActor from implementing multiple Types (interfaces).

I thought I had read someplace that Akka 2.0 was going to change this. Does anyone have any thoughts on this, or how to workaround? FYI, I am using Akka in pure Java, not Scala at this stage

도움이 되었습니까?

해결책

Typed Actors in pre-2.0 are implemented using aspect weaving, and are thus not JDK proxies.

Typed Actors in 2.x are based on JDK proxies and you can essentially use as many interfaces as is supprted by the JDK: Supercharging

다른 팁

There is an official opinion that Typed actors are not the best (see When_to_use_Typed_Actors). If it is possible try to use Untyped actors with typed messages.

We have been using the messages of the kind:

class Contact<T>
class Signal<T>(contact:Contact<T>, data:T)

The instance of contact is easy to check on equality. (if-elseif-elseif) Usually a map of contact-handlers is sufficient to handle all inputs.

The idea of strictly typed signals is further developed in SynapseGrid library. It defines Builder to associate typed handlers with typed contacts.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top