Class MessageOriginProvider

java.lang.Object
org.axonframework.messaging.correlation.MessageOriginProvider
All Implemented Interfaces:
CorrelationDataProvider

public class MessageOriginProvider extends Object implements CorrelationDataProvider
CorrelationDataProvider that provides the identifier of a Message to other messages that are created as result of processing the first message.
Author:
Rene de Waele
  • Constructor Details

    • MessageOriginProvider

      public MessageOriginProvider()
      Initializes a MessageOriginProvider that uses the default correlation id key: getDefaultCorrelationKey() and trace id key: getDefaultTraceKey().
    • MessageOriginProvider

      public MessageOriginProvider(String correlationKey, String traceKey)
      Initializes a MessageOriginProvider that uses the given correlationKey.
      Parameters:
      correlationKey - the key used to store the identifier of a message in the metadata of a resulting message
      traceKey - the key used to store the identifier of the original message giving rise to the current message
  • Method Details

    • getDefaultCorrelationKey

      public static String getDefaultCorrelationKey()
      Returns the default metadata key for the correlation id of a message.
      Returns:
      the default metadata key for the correlation id
    • getDefaultTraceKey

      public static String getDefaultTraceKey()
      Returns the default metadata key for the trace id of a message.
      Returns:
      the default metadata key for the trace id
    • correlationDataFor

      public Map<String,?> correlationDataFor(Message<?> message)
      Description copied from interface: CorrelationDataProvider
      Provides a map with the entries to attach as correlation data to generated messages while processing given message.

      This method should not return null. Any exception thrown from this method might interfere with rolling back a transaction. Therefore, by default exceptions are caught, ignoring the correlation data that should have been added.

      Specified by:
      correlationDataFor in interface CorrelationDataProvider
      Parameters:
      message - The message to define correlation data for
      Returns:
      the data to attach as correlation data to generated messages