Annotation Interface AggregateMember


@Documented @Target({FIELD,METHOD,ANNOTATION_TYPE}) @Retention(RUNTIME) public @interface AggregateMember
Marker annotation for a Field or Method that references one or more Entities capable of handling Commands or Events. The annotation may be placed on a member referencing a single Entity, a member referencing a Collection of Entities, or a Map containing Entities mapped by their identifier.

If the annotation is placed on a Collection of Entities, an Entity is selected for Command handling based on the Entity's identifier and the value of the routing key property on the Command. See EntityId for more information.

If the annotation is placed on a Map of Entities, the key of the Map should be equal to the Entity's identifier. Note that Entities in the Map still need to specify which routing key to use. To that end Entities should contain a EntityId annotated identifier field. Usually it is advantageous in terms of performance to store Entities in a Map instead of Collection.

Note that if the designated Aggregate member has CommandHandler annotations to handle Command message, that those may not be placed on an non-root Entity's constructor.

Since:
3.0
Author:
Allard Buijze
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Indicates the forwarding mode used for events within this entity.
    boolean
    Indicates whether commands should be forwarded to this AggregateMember.
    The property of the message to be used as a routing key towards this Aggregate Member.
    Provides the member's type.
  • Element Details

    • forwardCommands

      boolean forwardCommands
      Indicates whether commands should be forwarded to this AggregateMember. Defaults to true.
      Default:
      true
    • eventForwardingMode

      Class<? extends ForwardingMode> eventForwardingMode
      Indicates the forwarding mode used for events within this entity. Defaults to ForwardToAll to forward all events to all entities referred to by the annotated field.
      Default:
      org.axonframework.modelling.command.ForwardToAll.class
    • routingKey

      String routingKey
      The property of the message to be used as a routing key towards this Aggregate Member. Defaults to "", which deeper down defaults to the EntityId annotated field or that annotation its routingKey property.
      Default:
      ""
    • type

      Class<?> type
      Provides the member's type. By default the type of member is determined from the field's (generic) type.
      Default:
      java.lang.Void.class