-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActorRef serialization: transportInformation should be set #179
Comments
…uld be set Signed-off-by: Gaël Bréard <gael.breard@orange.com>
Hi @gbrd , Ok so this never worked? That's surprising. I guess the issue wouldn't show up if the sender was local? From what I have been able to tell, we're currently delegating to the Can you provide more information? I'm just struggling with this issue, sorry. I'm also pretty concerned about adding a dependency on an undocumented (other than the big warning comment |
Hi @scullxbones To be honest the API sounds very strange to me too, but I don't master this code completely. I understood it's a kind of optimization/trick. Steps to reproduce :
Main : import akka.actor.{ActorRef, ActorSystem, Props}
import akka.cluster.sharding.{ClusterSharding, ClusterShardingSettings, ShardRegion}
import akka.pattern.ask
import akka.util.Timeout
import scala.concurrent.duration._
object AkkaQuickstart extends App {
// Create the 'helloAkka' actor system
val system: ActorSystem = ActorSystem("ClusterSystem")
implicit val timeout: Timeout = 10.seconds
implicit val ec = system.dispatcher
val extractEntityId: ShardRegion.ExtractEntityId = {
case EntityEnvelope(id, payload) ⇒ (id.toString, payload)
case msg@Get(id) ⇒ (id.toString, msg)
}
val numberOfShards = 100
val extractShardId: ShardRegion.ExtractShardId = {
case EntityEnvelope(id, _) ⇒ (id % numberOfShards).toString
case Get(id) ⇒ (id % numberOfShards).toString
case ShardRegion.StartEntity(id) ⇒
// StartEntity is used by remembering entities feature
(id.toLong % numberOfShards).toString
}
val counterRegion: ActorRef = ClusterSharding(system).start(
typeName = "Counter",
entityProps = Props[Counter],
settings = ClusterShardingSettings(system),
extractEntityId = extractEntityId,
extractShardId = extractShardId)
counterRegion ! EntityEnvelope(0,Increment)
(counterRegion ? Get(0)).mapTo[Int].onComplete {
case c => println("counter = " + c)
} Counter actor: import akka.actor.ReceiveTimeout
import akka.persistence.PersistentActor
import akka.cluster.sharding.ShardRegion
import scala.concurrent.duration._
case object Increment
case object Decrement
final case class Get(counterId: Long)
final case class EntityEnvelope(id: Long, payload: Any)
case object Stop
final case class CounterChanged(delta: Int)
object Counter {
}
class Counter extends PersistentActor {
import ShardRegion.Passivate
context.setReceiveTimeout(120.seconds)
// self.path.name is the entity identifier (utf-8 URL-encoded)
override def persistenceId: String = "Counter-" + self.path.name
var count = 0
def updateState(event: CounterChanged): Unit = {
count += event.delta
}
override def receiveRecover: Receive = {
case evt: CounterChanged ⇒ updateState(evt)
}
override def receiveCommand: Receive = {
case Increment ⇒ persist(CounterChanged(+1))(updateState)
case Decrement ⇒ persist(CounterChanged(-1))(updateState)
case Get(_) ⇒ sender() ! count
case ReceiveTimeout ⇒ context.parent ! Passivate(stopMessage = Stop)
case Stop ⇒ context.stop(self)
}
} Config file:
build.sbt
|
My patch does not work for casbah because of Do you think that we should duplicate the code in CasbahPersistenceJournaller and RxMongoJournaller ? |
Can it be done in I feel a lot better about this in general with the new public API being added to def withTransportInformation(system: ExtendedActorSystem)(f: () => Unit): Unit Or something to that effect. |
Also, is there a way to add a test for this? Seems like it would be difficult but I thought i'd at least ask. |
Yes it would be much better in |
I'd be okay with that - it's not clear though when that would be coming. Can implement against the old internal API I guess for now. Is this issue blocking you currently? |
Yes and no, I "overloaded" the class in my protect.. |
…uld be set Signed-off-by: Gaël Bréard <gael.breard@orange.com>
I modified the fix with a cleaner solution. |
This is in the |
ActorRef serialization: transportInformation should be set (Add serialization with transport information method in public API) Signed-off-by: Gaël Bréard <gael.breard@orange.com>
* fix: replace fix #179 with akka/akka #24321 ActorRef serialization: transportInformation should be set (Add serialization with transport information method in public API) Signed-off-by: Gaël Bréard <gael.breard@orange.com> * fix: remove SerializationHelper itself, do missing change in rxmongo Signed-off-by: Gaël Bréard <gael.breard@orange.com>
Please see akka/akka#24321 for details.
I will try to submit a PR
The text was updated successfully, but these errors were encountered: