In Vaughn Vernon's book "Reactive Messaging Patterns with the Actor Model" 
i discovered the "Messaging Gateway" pattern to implement a transient actor 
lifetime for actors with aggregate (in a DDD sense) characteristics which 
was exactly what i needed for a CQRS style architecture based on 
akka-persistence. In the example an "AggregateRef" is used as a wrapper for 
an ActorRef to instantiate an actor on demand as soon as there is an 
attempt to send a message to the actor. The AggregateRef is implemented as 
follows (The full example can be found on github 
<https://github.com/VaughnVernon/ReactiveMessagingPatterns_ActorModel/blob/master/src/co/vaughnvernon/reactiveenterprise/domainmodel/DomainModelPrototype.scala>
):

case class AggregateRef(id: String, cache: ActorRef) {
  def !(message: Any)(implicit sender: ActorRef = null): Unit = {
    cache ! CacheMessage(id, message, sender);
  }
}

This basically wraps the tell method which works fine. Now i need to do the 
same for the ask pattern which i can't manage to get right. I don't know 
how to properly set up the sender as it is not an actor. I discovered this 
normally works with a PromiseActorRef which i don't know how to 
setup/inject here.

Any ideas on this?

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to