Class MessageOriginProvider

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

public class MessageOriginProvider extends Object implements CorrelationDataProvider
A CorrelationDataProvider implementation that provides the identifier of a Message to other Messages that are created as result of processing the given message.

By defaults uses the DEFAULT_CORRELATION_KEY as the metadata key for the "correlation identifier," which refers to the original message identifier starting the entire business transaction / workflow. The DEFAULT_CAUSATION_KEY is used as the metadata key for the "causation identifier," referring to the message identifier preceding it.

Since:
3.0.0
Author:
Rene de Waele
  • Field Details

  • Constructor Details

    • MessageOriginProvider

      public MessageOriginProvider()
      Initializes a MessageOriginProvider using the DEFAULT_CORRELATION_KEY and DEFAULT_CAUSATION_KEY as the correlationKey and causationKey respectively.
    • MessageOriginProvider

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

    • correlationDataFor

      @Nonnull public Map<String,String> correlationDataFor(@Nonnull 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.