Interface CommandContext

All Superinterfaces:
Context, MetadataContext

public interface CommandContext extends MetadataContext
Context information available to Event Sourced Entity command handlers during command processing. Provides access to command metadata, entity identification, sequence information, and tracing capabilities.

This context is automatically provided by the Akka runtime and can be accessed within command handlers using EventSourcedEntity.commandContext().

  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Deprecated.
    This method is no longer used and will be removed in a future version
    Returns the name of the command currently being executed.
    Returns the unique identifier of the entity instance that this command is being executed on.
    boolean
    Returns whether this entity has been marked for deletion.
    long
    Returns the current sequence number of events in this entity.
    Provides access to tracing functionality for adding custom application-specific tracing information to the current command processing.

    Methods inherited from interface akka.javasdk.Context

    selfRegion

    Methods inherited from interface akka.javasdk.MetadataContext

    metadata
  • Method Details

    • sequenceNumber

      long sequenceNumber()
      Returns the current sequence number of events in this entity. This represents the number of events that have been persisted for this entity instance.
      Returns:
      the current sequence number of persisted events
    • commandName

      String commandName()
      Returns the name of the command currently being executed. This corresponds to the method name of the command handler being invoked.
      Returns:
      the name of the command being processed
    • commandId

      @Deprecated long commandId()
      Deprecated.
      This method is no longer used and will be removed in a future version
      Returns the command id for the current command.
      Returns:
      the command id
    • entityId

      String entityId()
      Returns the unique identifier of the entity instance that this command is being executed on. This is the same id used when calling the entity through a component client.
      Returns:
      the unique entity id for this entity instance
    • isDeleted

      boolean isDeleted()
      Returns whether this entity has been marked for deletion.
      Returns:
      true if the entity has been deleted, false otherwise
    • tracing

      Tracing tracing()
      Provides access to tracing functionality for adding custom application-specific tracing information to the current command processing.
      Returns:
      the tracing context for custom tracing operations