Class TestEntityRefImpl<M>
- java.lang.Object
-
- akka.cluster.sharding.typed.javadsl.EntityRef<M>
-
- akka.cluster.sharding.typed.internal.testkit.TestEntityRefImpl<M>
-
- All Implemented Interfaces:
InternalRecipientRef<M>
,RecipientRef<M>
,EntityRef<M>
public final class TestEntityRefImpl<M> extends EntityRef<M> implements EntityRef<M>, InternalRecipientRef<M>
INTERNAL API
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface akka.actor.typed.RecipientRef
RecipientRef.RecipientRefOps<T>, RecipientRef.RecipientRefOps$
-
-
Constructor Summary
Constructors Constructor Description TestEntityRefImpl(java.lang.String entityId, ActorRef<M> probe, EntityTypeKey<M> typeKey)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EntityRef<M>
asJava()
INTERNAL API<U> java.util.concurrent.CompletionStage<U>
ask(Function<ActorRef<U>,M> message, java.time.Duration timeout)
Allows to "ask" theEntityRef
for a reply.<U> scala.concurrent.Future<U>
ask(scala.Function1<ActorRef<U>,M> message, Timeout timeout)
Allows to "ask" theEntityRef
for a reply.<Res> scala.concurrent.Future<Res>
askWithStatus(scala.Function1<ActorRef<StatusReply<Res>>,M> f, Timeout timeout)
The same asEntityRef.<Res>ask(scala.Function1<akka.actor.typed.ActorRef<Res>,M>,akka.util.Timeout)
but only for requests that result in a response of typeStatusReply
.<Res> java.util.concurrent.CompletionStage<Res>
askWithStatus(scala.Function1<ActorRef<StatusReply<Res>>,M> f, java.time.Duration timeout)
The same asEntityRef.<Res>ask(akka.japi.function.Function<akka.actor.typed.ActorRef<Res>,M>,java.time.Duration)
but only for requests that result in a response of typeStatusReply
.scala.Option<java.lang.String>
dataCenter()
The specified datacenter of the incarnation of the particular entity referenced by this EntityRef, if a datacenter was specified.java.lang.String
entityId()
The identifier for the particular entity referenced by this EntityRef.boolean
isTerminated()
ActorRefProvider
provider()
Get a reference to the actor ref provider which created this ref.void
tell(M msg)
Send a message to the entity referenced by this EntityRef using *at-most-once* messaging semantics.java.lang.String
toString()
EntityTypeKey<M>
typeKey()
The EntityTypeKey associated with this EntityRef.-
Methods inherited from class akka.cluster.sharding.typed.javadsl.EntityRef
asScala, getDataCenter, getEntityId, getTypeKey
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface akka.actor.typed.internal.InternalRecipientRef
refPrefix
-
-
-
-
Constructor Detail
-
TestEntityRefImpl
public TestEntityRefImpl(java.lang.String entityId, ActorRef<M> probe, EntityTypeKey<M> typeKey)
-
-
Method Detail
-
ask
public <U> scala.concurrent.Future<U> ask(scala.Function1<ActorRef<U>,M> message, Timeout timeout)
Description copied from interface:EntityRef
Allows to "ask" theEntityRef
for a reply. SeeAskPattern
for a complete write-up of this patternNote that if you are inside of an actor you should prefer
akka.actor.typed.scaladsl.ActorContext.ask
as that provides better safety.Example usage:
case class Request(msg: String, replyTo: ActorRef[Reply]) case class Reply(msg: String) implicit val timeout = Timeout(3.seconds) val target: EntityRef[Request] = ... val f: Future[Reply] = target.ask(Request("hello", _))
Please note that an implicit
Timeout
must be available to use this pattern.
-
ask
public <U> java.util.concurrent.CompletionStage<U> ask(Function<ActorRef<U>,M> message, java.time.Duration timeout)
Description copied from class:EntityRef
Allows to "ask" theEntityRef
for a reply. SeeAskPattern
for a complete write-up of this patternNote that if you are inside of an actor you should prefer
akka.actor.typed.javadsl.ActorContext.ask
as that provides better safety.
-
askWithStatus
public <Res> java.util.concurrent.CompletionStage<Res> askWithStatus(scala.Function1<ActorRef<StatusReply<Res>>,M> f, java.time.Duration timeout)
Description copied from class:EntityRef
The same asEntityRef.<Res>ask(akka.japi.function.Function<akka.actor.typed.ActorRef<Res>,M>,java.time.Duration)
but only for requests that result in a response of typeStatusReply
. If the response is aStatusReply.success(T)
the returned future is completed successfully with the wrapped response. If the status response is aStatusReply.error(java.lang.String)
the returned future will be failed with the exception in the error (normally aStatusReply.ErrorMessage
).- Specified by:
askWithStatus
in classEntityRef<M>
-
askWithStatus
public <Res> scala.concurrent.Future<Res> askWithStatus(scala.Function1<ActorRef<StatusReply<Res>>,M> f, Timeout timeout)
Description copied from interface:EntityRef
The same asEntityRef.<Res>ask(scala.Function1<akka.actor.typed.ActorRef<Res>,M>,akka.util.Timeout)
but only for requests that result in a response of typeStatusReply
. If the response is aakka.pattern.StatusReply.Success
the returned future is completed successfully with the wrapped response. If the status response is aakka.pattern.StatusReply.Error
the returned future will be failed with the exception in the error (normally aStatusReply.ErrorMessage
).- Specified by:
askWithStatus
in interfaceEntityRef<M>
-
dataCenter
public scala.Option<java.lang.String> dataCenter()
Description copied from interface:EntityRef
The specified datacenter of the incarnation of the particular entity referenced by this EntityRef, if a datacenter was specified.- Specified by:
dataCenter
in interfaceEntityRef<M>
-
entityId
public java.lang.String entityId()
Description copied from interface:EntityRef
The identifier for the particular entity referenced by this EntityRef.// given sharding, typeKey sharding.entityRefFor(typeKey, "someId").entityId == "someId" // always true
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfaceInternalRecipientRef<M>
- Returns:
true
if the actor is locally known to be terminated,false
if alive or uncertain.
-
provider
public ActorRefProvider provider()
Description copied from interface:InternalRecipientRef
Get a reference to the actor ref provider which created this ref.- Specified by:
provider
in interfaceInternalRecipientRef<M>
-
tell
public void tell(M msg)
Description copied from class:EntityRef
Send a message to the entity referenced by this EntityRef using *at-most-once* messaging semantics.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-