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 |
andAutoStart(boolean autoStart)
Whether to automatically start the processor when event processing is initialized.
|
TrackingEventProcessorConfiguration |
andBatchSize(int batchSize)
Set the maximum number of events that may be processed in a single transaction.
|
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)
Sets the initial number of segments for asynchronous processing.
|
TrackingEventProcessorConfiguration |
andInitialTrackingToken(Function<StreamableMessageSource<TrackedEventMessage<?>>,TrackingToken> initialTrackingTokenBuilder)
Sets the builder to use to create the initial
TrackingToken . |
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.
|
TrackingEventProcessorConfiguration |
andWorkerTerminationTimeout(long workerTerminationTimeoutInMilliseconds)
Deprecated.
Use
andWorkerTerminationTimeout(long, TimeUnit) instead. |
TrackingEventProcessorConfiguration |
andWorkerTerminationTimeout(long workerTerminationTimeout,
TimeUnit timeUnit)
Sets the shutdown timeout to terminate active workers.
|
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()
Return the maximum number of events to process in a single batch.
|
int |
getEventAvailabilityTimeout()
Return the time, in milliseconds, that a processor should wait for available events before going into a cycle of
updating claims and checking for incoming instructions.
|
EventTrackerStatusChangeListener |
getEventTrackerStatusChangeListener()
Returns the
EventTrackerStatusChangeListener defined in this configuration, to be called whenever an
EventTrackerStatus change occurs. |
int |
getInitialSegmentsCount()
Return the number of segments requested for handling asynchronous processing of events.
|
Function<StreamableMessageSource<TrackedEventMessage<?>>,TrackingToken> |
getInitialTrackingToken()
Return the builder function of the initial
TrackingToken . |
int |
getMaxThreadCount()
Return the pool size of core threads as per
ThreadPoolExecutor.getCorePoolSize() . |
ThreadFactory |
getThreadFactory(String processorName)
|
long |
getTokenClaimInterval()
Returns the time, in milliseconds, the processor should wait after a failed attempt to claim any segments for
processing.
|
long |
getWorkerTerminationTimeout()
Returns the timeout to terminate workers during a
TrackingEventProcessor.shutDown() . |
boolean |
isAutoStart()
Return a
boolean dictating whether the processor should start automatically when the application starts. |
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 parallel.public TrackingEventProcessorConfiguration andBatchSize(int batchSize)
1
.batchSize
- The maximum number of events to process in a single batch.this
for method chaining.public TrackingEventProcessorConfiguration andInitialSegmentsCount(int segmentsSize)
initial tracking token
builder method for fresh
TrackingEventProcessors
.
This value is only used whenever there are no TrackingTokens
present for the
TrackingEventProcessor
this configuration is used on.
segmentsSize
- The number of segments requested for handling asynchronous processing of events.this
for method chaining.public TrackingEventProcessorConfiguration andThreadFactory(@Nonnull Function<String,ThreadFactory> threadFactory)
ThreadFactory
to use to create the Threads
to process events on. Each segment
will be processed by a separate thread.threadFactory
- The ThreadFactory
to create Threads
with.this
for method chaining.public 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 extended.unit
- The unit in which the interval is expressed.this
for method chaining.public TrackingEventProcessorConfiguration andInitialTrackingToken(@Nonnull Function<StreamableMessageSource<TrackedEventMessage<?>>,TrackingToken> initialTrackingTokenBuilder)
TrackingToken
. This token is used by the processor as a
starting point.
Defaults to an automatic replay since the start of the stream.
More specifically, it defaults to a ReplayToken
that starts streaming
from the tail
with the replay flag enabled until the
head
at the moment of initialization is reached.
initialTrackingTokenBuilder
- The builder of the initial TrackingToken
.this
for method chaining.public TrackingEventProcessorConfiguration andTokenClaimInterval(long tokenClaimInterval, @Nonnull TimeUnit timeUnit)
tokenClaimInterval
- The time to wait in between attempts to claim a token.timeUnit
- The unit of time.this
for method chaining.public TrackingEventProcessorConfiguration andAutoStart(boolean autoStart)
false
, the
application must explicitly start the processor. This can be useful if the application needs to perform its own
initialization before it begins processing new events.
The autostart setting does not impact the shutdown process of the processor. It will always be triggered when the framework receives a signal to shut down.
autoStart
- true
to automatically start the processor (the default), false
if the
application will start the processor itself.this
for method chaining.public TrackingEventProcessorConfiguration andEventTrackerStatusChangeListener(@Nonnull EventTrackerStatusChangeListener eventTrackerStatusChangeListener)
EventTrackerStatusChangeListener
which will be called on EventTrackerStatus
changes.
Defaults to EventTrackerStatusChangeListener.noOp()
.
eventTrackerStatusChangeListener
- The EventTrackerStatusChangeListener
to use.this
for method chaining.@Deprecated public TrackingEventProcessorConfiguration andWorkerTerminationTimeout(long workerTerminationTimeoutInMilliseconds)
andWorkerTerminationTimeout(long, TimeUnit)
instead.This is used for both the graceful termination and the potential forced termination of active workers. It is thus possible that it is used twice during the shutdown phase. Defaults to 5000ms.
workerTerminationTimeoutInMilliseconds
- The timeout for workers to terminate on a shutdown in
milliseconds.this
for method chaining.public TrackingEventProcessorConfiguration andWorkerTerminationTimeout(long workerTerminationTimeout, TimeUnit timeUnit)
This is used for both the graceful termination and the potential forced termination of active workers. It is thus possible that it is used twice during the shutdown phase. Defaults to 5000ms.
workerTerminationTimeout
- The timeout for workers to terminate on a shutdown.timeUnit
- The unit of time.this
for method chaining.public int getBatchSize()
public int getInitialSegmentsCount()
public Function<StreamableMessageSource<TrackedEventMessage<?>>,TrackingToken> getInitialTrackingToken()
TrackingToken
.TrackingToken
.public int getMaxThreadCount()
ThreadPoolExecutor.getCorePoolSize()
.ThreadPoolExecutor.getCorePoolSize()
.public int getEventAvailabilityTimeout()
public ThreadFactory getThreadFactory(String processorName)
processorName
- The name of the processor for which to return the ThreadFactory
.ThreadFactory
.public long getTokenClaimInterval()
andTokenClaimInterval(long, TimeUnit)
public boolean isAutoStart()
boolean
dictating whether the processor should start automatically when the application starts.true
if the processor should be started automatically by the framework.public EventTrackerStatusChangeListener getEventTrackerStatusChangeListener()
EventTrackerStatusChangeListener
defined in this configuration, to be called whenever an
EventTrackerStatus
change occurs.EventTrackerStatusChangeListener
defined in this configuration.public long getWorkerTerminationTimeout()
TrackingEventProcessor.shutDown()
.TrackingEventProcessor.shutDown()
.Copyright © 2010–2024. All rights reserved.