Package org.axonframework.eventhandling
Class MultiStreamableMessageSource.Builder
java.lang.Object
org.axonframework.eventhandling.MultiStreamableMessageSource.Builder
- Direct Known Subclasses:
MultiStreamableMessageSource.Builder
- Enclosing class:
MultiStreamableMessageSource
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMessageSource(String messageSourceId, StreamableMessageSource<TrackedEventMessage<?>> messageSource) Adds a message source to the list of sources.build()Initializes aMultiStreamableMessageSourceas specified through this Builder.longPollingSource(String longPollingSource) Select the message source which is most suitable for long polling.trackedEventComparator(Comparator<Map.Entry<String, TrackedEventMessage<?>>> trackedEventComparator) Overrides the default trackedEventComparator.
-
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
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 usingBlockingStream.hasNextAvailable()beforeBlockingStream.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 usingBlockingStream.hasNextAvailable().- Parameters:
longPollingSource- ThemessageSourceNameon which to do the long polling.- Returns:
- The current Builder instance, for fluent interfacing.
-
build
Initializes aMultiStreamableMessageSourceas specified through this Builder.- Returns:
- a
MultiStreamableMessageSourceas specified through this Builder.
-