Class ShardingEnvelope<M>

java.lang.Object
org.apache.pekko.cluster.sharding.typed.ShardingEnvelope<M>
All Implemented Interfaces:
Serializable, WrappedMessage, scala.Equals, scala.Product

public final class ShardingEnvelope<M> extends Object implements WrappedMessage, scala.Product, Serializable
Default envelope type that may be used with Cluster Sharding.

Cluster Sharding provides a default HashCodeMessageExtractor that is able to handle these types of messages, by hashing the entityId into into the shardId. It is not the only, but a convenient way to send envelope-wrapped messages via cluster sharding.

The alternative way of routing messages through sharding is to not use envelopes, and have the message types themselves carry identifiers.

param: entityId The business domain identifier of the entity. param: message The message to be send to the entity.

See Also:
  • Constructor Details

    • ShardingEnvelope

      public ShardingEnvelope(String entityId, M message)
  • Method Details

    • apply

      public static <M> ShardingEnvelope<M> apply(String entityId, M message)
    • unapply

      public static <M> scala.Option<scala.Tuple2<String,M>> unapply(ShardingEnvelope<M> x$0)
    • entityId

      public String entityId()
    • message

      public M message()
      Specified by:
      message in interface WrappedMessage
    • copy

      public <M> ShardingEnvelope<M> copy(String entityId, M message)
    • copy$default$1

      public <M> String copy$default$1()
    • copy$default$2

      public <M> M copy$default$2()
    • productPrefix

      public String productPrefix()
      Specified by:
      productPrefix in interface scala.Product
    • productArity

      public int productArity()
      Specified by:
      productArity in interface scala.Product
    • productElement

      public Object productElement(int x$1)
      Specified by:
      productElement in interface scala.Product
    • productIterator

      public scala.collection.Iterator<Object> productIterator()
      Specified by:
      productIterator in interface scala.Product
    • canEqual

      public boolean canEqual(Object x$1)
      Specified by:
      canEqual in interface scala.Equals
    • productElementName

      public String productElementName(int x$1)
      Specified by:
      productElementName in interface scala.Product
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object x$1)
      Specified by:
      equals in interface scala.Equals
      Overrides:
      equals in class Object