Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1362

Ask Pattern with Shard Region

$
0
0

@alan.brewster73 wrote:

Hi,

How do I do an ask with a Shard Region? Currently, I am asking the entity reference directly as shown below.

val sharding = ClusterSharding(system)
val shardRegion = sharding.init(Entity(ShoppingCartActor.TypeKey)(createBehavior = entityContext => ShoppingCartActor()))

def addItem(id: String, quantity: Int) : Future[CartState] = {
  val entityRef = sharding.entityRefFor(ShoppingCartActor.TypeKey, "Cart")
  entityRef ? (ShoppingCartActor.AddItem(id, quantity, _))
}

Kind regards

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 1362

Trending Articles