Annotation Interface Trigger


@Documented @Target({PARAMETER,METHOD}) @Retention(RUNTIME) public @interface Trigger
Annotation to be placed on a message handler parameter or message handler method. The handler is only invoked if the trigger for the message matches the requirements configured in the annotation.

If present on a parameter, the message that triggered the handled message is injected into the parameter if the parameter type is assignable from the trigger message type.

This is typically useful when handling results (using HandleResult) or errors (using HandleError). In those handlers it is often useful to have access to the message that triggered the result or error.

Valid parameter types are types that can be assigned from the trigger message payload type, or Message or DeserializingMessage. Using value() it is possible to filter what trigger messages to listen for. If value() is left empty any trigger that matches the parameter is injected. Using messageType() it is possible to filter the MessageType of the trigger message.

It is also possible to only listen for messages that were triggered by a given consumer using consumer().

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Filter on the name of the consumer that produced the handled message.
    Filter what trigger messages may be injected.
    Class<?>[]
    Filter what trigger messages may be injected.
  • Element Details

    • value

      Class<?>[] value
      Filter what trigger messages may be injected. Parameters are only injected if the trigger message payload type can be assigned to any of the given classes.

      If left empty, any trigger that matches the parameter is injected.

      Default:
      {}
    • messageType

      MessageType[] messageType
      Filter what trigger messages may be injected. Parameters are only injected if the trigger message type is contained in the returned array, or if the array is left empty.
      Default:
      {}
    • consumer

      String[] consumer
      Filter on the name of the consumer that produced the handled message. If multiple values are given, the match is made if any of the mentioned consumers produced the message.

      This makes it easy to e.g. track results or errors produced by one or more consumers.

      Default:
      {}