public class TrackingEventProcessorConfiguration extends Object
TrackingEventProcessor
. The TrackingEventProcessorConfiguration provides access
to the options to tweak various settings. Instances are not thread-safe and should not be altered after they have
been used to initialize a TrackingEventProcessor.Modifier and Type | Method and Description |
---|---|
TrackingEventProcessorConfiguration |
andBatchSize(int batchSize) |
TrackingEventProcessorConfiguration |
andEventAvailabilityTimeout(long interval,
TimeUnit unit)
Set the duration where a Tracking Processor will wait for the availability of Events, in each cycle, before
extending the claim on the tokens it owns.
|
TrackingEventProcessorConfiguration |
andEventTrackerStatusChangeListener(EventTrackerStatusChangeListener eventTrackerStatusChangeListener)
Sets the
EventTrackerStatusChangeListener which will be called on EventTrackerStatus changes. |
TrackingEventProcessorConfiguration |
andInitialSegmentsCount(int segmentsSize) |
TrackingEventProcessorConfiguration |
andInitialTrackingToken(Function<StreamableMessageSource<TrackedEventMessage<?>>,TrackingToken> initialTrackingTokenBuilder)
Sets the Builder to use to create the initial tracking token.
|
TrackingEventProcessorConfiguration |
andThreadFactory(Function<String,ThreadFactory> threadFactory)
Sets the ThreadFactory to use to create the threads to process events on.
|
TrackingEventProcessorConfiguration |
andTokenClaimInterval(long tokenClaimInterval,
TimeUnit timeUnit)
Sets the time to wait after a failed attempt to claim any token, before making another attempt.
|
static TrackingEventProcessorConfiguration |
forParallelProcessing(int threadCount)
Initialize a configuration instance with the given
threadCount . |
static TrackingEventProcessorConfiguration |
forSingleThreadedProcessing()
Initialize a configuration with single threaded processing.
|
int |
getBatchSize() |
int |
getEventAvailabilityTimeout() |
EventTrackerStatusChangeListener |
getEventTrackerStatusChangeListener()
Returns the
EventTrackerStatusChangeListener defined in this configuration, to be called whenever an
EventTrackerStatus change occurs. |
int |
getInitialSegmentsCount() |
Function<StreamableMessageSource<TrackedEventMessage<?>>,TrackingToken> |
getInitialTrackingToken() |
int |
getMaxThreadCount() |
ThreadFactory |
getThreadFactory(String processorName)
Provides the ThreadFactory to use to construct Threads for the processor with given
processorName |
long |
getTokenClaimInterval()
Returns the time, in milliseconds, the processor should wait after a failed attempt to claim any segments for
processing.
|
public static TrackingEventProcessorConfiguration forSingleThreadedProcessing()
public static TrackingEventProcessorConfiguration forParallelProcessing(int threadCount)
threadCount
. This is both the number of threads that a
processor will start for processing, as well as the initial number of segments that will be created when the
processor is first started.threadCount
- the number of segments to process in parallelpublic TrackingEventProcessorConfiguration andBatchSize(int batchSize)
batchSize
- The maximum number of events to process in a single batch.this
for method chainingpublic TrackingEventProcessorConfiguration andInitialSegmentsCount(int segmentsSize)
segmentsSize
- The number of segments requested for handling asynchronous processing of events.this
for method chainingpublic TrackingEventProcessorConfiguration andThreadFactory(Function<String,ThreadFactory> threadFactory)
threadFactory
- The factory to create threads withthis
for method chainingpublic TrackingEventProcessorConfiguration andEventAvailabilityTimeout(long interval, TimeUnit unit)
Note that some storage engines for the EmbeddedEventStore do not support streaming. They may poll for messages
once on an BlockingStream.hasNextAvailable(int, TimeUnit)
invocation, and wait for the timeout to
occur.
This value should be significantly shorter than the claim timeout configured on the Token Store. Failure to do so may cause claims to be stolen while a tread is waiting for events. Also, with very long timeouts, it will take longer for threads to pick up the instructions they need to process.
Defaults to 1 second.
The given value must be strictly larger than 0, and may not exceed Integer.MAX_VALUE
milliseconds.
interval
- The interval in which claims on segments need to be extendedunit
- The unit in which the interval is expressedthis
for method chainingpublic TrackingEventProcessorConfiguration andInitialTrackingToken(Function<StreamableMessageSource<TrackedEventMessage<?>>,TrackingToken> initialTrackingTokenBuilder)
initialTrackingTokenBuilder
- The Builder of initial tracking tokenthis
for method chainingpublic TrackingEventProcessorConfiguration andTokenClaimInterval(long tokenClaimInterval, TimeUnit timeUnit)
tokenClaimInterval
- The time to wait in between attempts to claim a tokentimeUnit
- The unit of timethis
for method chainingpublic TrackingEventProcessorConfiguration andEventTrackerStatusChangeListener(EventTrackerStatusChangeListener eventTrackerStatusChangeListener)
EventTrackerStatusChangeListener
which will be called on EventTrackerStatus
changes.
Defaults to EventTrackerStatusChangeListener.noOp()
.eventTrackerStatusChangeListener
- the EventTrackerStatusChangeListener
to usethis
for method chainingpublic int getBatchSize()
public int getInitialSegmentsCount()
public Function<StreamableMessageSource<TrackedEventMessage<?>>,TrackingToken> getInitialTrackingToken()
public int getMaxThreadCount()
ThreadPoolExecutor.getCorePoolSize()
public int getEventAvailabilityTimeout()
public ThreadFactory getThreadFactory(String processorName)
processorName
processorName
- The name of the processor for which to return the ThreadFactorypublic long getTokenClaimInterval()
andTokenClaimInterval(long, TimeUnit)
public EventTrackerStatusChangeListener getEventTrackerStatusChangeListener()
EventTrackerStatusChangeListener
defined in this configuration, to be called whenever an
EventTrackerStatus
change occurs.EventTrackerStatusChangeListener
defined in this configurationCopyright © 2010–2022. All rights reserved.