Hello

I wanted to ask here before posting an issue on GitHub. 

Some of the messages I am sending to my PersistentActors need to be wrapped 
in the envelope.

In the source code of the ClusterSharding it says that ShardResolver will 
receive messages that passed through IdResolver, and also IdResolver 
returns the message to send to the cluster sharded actor.

The problem is that based on my experiments and on the source code of the 
ClusterSharding module it seems that the message returned by IdResolver is 
not passed to ShardResolver because it receives original message (and not 
the one returned by the IdExtractor).

Relevant code:

receive method of ShardRegion:

def receive = {
>     case Terminated(ref)                     ⇒ receiveTerminated(ref)
>     case evt: ClusterDomainEvent             ⇒ receiveClusterEvent(evt)
>     case state: CurrentClusterState          ⇒ receiveClusterState(state)
>     case msg: CoordinatorMessage             ⇒ 
> receiveCoordinatorMessage(msg)
>     case cmd: ShardRegionCommand             ⇒ receiveCommand(cmd)
>     case msg if idExtractor.isDefinedAt(msg) ⇒ deliverMessage(msg, 
> sender())
>   }.


deliver message receives original message, and the code of deliverMessage

def deliverMessage(msg: Any, snd: ActorRef): Unit = {
>     val shard = shardResolver(msg)
>     regionByShard.get(shard) match {
>       case Some(ref) if ref == self ⇒
>         getShard(shard).tell(msg, snd)
>       case Some(ref) ⇒
>         log.debug("Forwarding request for shard [{}] to [{}]", shard, ref)
>         ref.tell(msg, snd)
>       case None if (shard == null || shard == "") ⇒
>         log.warning("Shard must not be empty, dropping message [{}]", 
> msg.getClass.getName)
>         context.system.deadLetters ! msg
>       case None ⇒
>         if (!shardBuffers.contains(shard)) {
>           log.debug("Request shard [{}] home", shard)
>           coordinator.foreach(_ ! GetShardHome(shard))
>         }
>         if (totalBufferSize >= bufferSize) {
>           log.debug("Buffer is full, dropping message for shard [{}]", 
> shard)
>           context.system.deadLetters ! msg
>         } else {
>           val buf = shardBuffers.getOrElse(shard, Vector.empty)
>           shardBuffers = shardBuffers.updated(shard, buf :+ ((msg, snd)))
>         }
>     }
>   }


shard resolver is invoked with original message.

My interpretation was that in some cases I can return different message 
through IdResolver and it will be used by ShardResolver to identify shard. 

-- 
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to