Class MultiStreamableMessageSource.Builder

java.lang.Object
org.axonframework.eventhandling.MultiStreamableMessageSource.Builder
Direct Known Subclasses:
MultiStreamableMessageSource.Builder
Enclosing class:
MultiStreamableMessageSource

public static class MultiStreamableMessageSource.Builder extends Object
Builder class to instantiate a MultiStreamableMessageSource. The configurable filed trackedEventComparator, which decides which message to process first if there is a choice defaults to the oldest message available (using the event's timestamp). The stream on which long polling is done for BlockingStream.hasNextAvailable(int, TimeUnit) is also configurable.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • addMessageSource

      public MultiStreamableMessageSource.Builder addMessageSource(String messageSourceId, StreamableMessageSource<TrackedEventMessage<?>> messageSource)
      Adds a message source to the list of sources.
      Parameters:
      messageSourceId - A unique name identifying the stream.
      messageSource - The message source to be added.
      Returns:
      The current Builder instance, for fluent interfacing.
    • trackedEventComparator

      public MultiStreamableMessageSource.Builder trackedEventComparator(Comparator<Map.Entry<String,TrackedEventMessage<?>>> trackedEventComparator)
      Overrides the default trackedEventComparator. The default trackedEventComparator returns the oldest event available: Comparator.comparing(EventMessage::getTimestamp).
      Parameters:
      trackedEventComparator - The trackedEventComparator to use when deciding on which message to return.
      Returns:
      The current Builder instance, for fluent interfacing.
    • longPollingSource

      public MultiStreamableMessageSource.Builder longPollingSource(String longPollingSource)
      Select the message source which is most suitable for long polling. To prevent excessive polling on all sources. If a source is not configured explicitly then it defaults to the last source provided. it is preferable to do the majority of polling on a single source. All other streams will be checked first using BlockingStream.hasNextAvailable() before BlockingStream.hasNextAvailable(int, TimeUnit) is called on the source chosen for long polling. This is then repeated multiple times to increase the chance of successfully finding a message before the timeout. If no particular source is configured, long polling will default to the last configured source whilst other streams will be polled using BlockingStream.hasNextAvailable().
      Parameters:
      longPollingSource - The messageSourceName on which to do the long polling.
      Returns:
      The current Builder instance, for fluent interfacing.
    • build

      Initializes a MultiStreamableMessageSource as specified through this Builder.
      Returns:
      a MultiStreamableMessageSource as specified through this Builder.