public static class MultiStreamableMessageSource.Builder extends Object
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
MultiSourceBlockingStream#hasNextAvailable(int, TimeUnit)
is also configurable.Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
MultiStreamableMessageSource.Builder |
addMessageSource(String messageSourceId,
StreamableMessageSource<TrackedEventMessage<?>> messageSource)
Adds a message source to the list of sources.
|
MultiStreamableMessageSource |
build()
Initializes a
MultiStreamableMessageSource as specified through this Builder. |
MultiStreamableMessageSource.Builder |
longPollingSource(String longPollingSource)
Select the message source which is most suitable for long polling.
|
MultiStreamableMessageSource.Builder |
trackedEventComparator(Comparator<Map.Entry<String,TrackedEventMessage<?>>> trackedEventComparator)
Overrides the default trackedEventComparator.
|
public MultiStreamableMessageSource.Builder addMessageSource(String messageSourceId, StreamableMessageSource<TrackedEventMessage<?>> messageSource)
messageSourceId
- A unique name identifying the stream.messageSource
- The message source to be added.public MultiStreamableMessageSource.Builder trackedEventComparator(Comparator<Map.Entry<String,TrackedEventMessage<?>>> trackedEventComparator)
Comparator.comparing(EventMessage::getTimestamp)
.trackedEventComparator
- The trackedEventComparator to use when deciding on which message to return.public MultiStreamableMessageSource.Builder longPollingSource(String longPollingSource)
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()
.longPollingSource
- The messageSourceName
on which to do the long polling.public MultiStreamableMessageSource build()
MultiStreamableMessageSource
as specified through this Builder.MultiStreamableMessageSource
as specified through this Builder.Copyright © 2010–2024. All rights reserved.