Class DefaultTracker
- java.lang.Object
-
- io.fluxcapacitor.javaclient.tracking.client.DefaultTracker
-
- All Implemented Interfaces:
Registration,Runnable
public class DefaultTracker extends Object implements Runnable, Registration
A tracker keeps reading messages until it is stopped (generally only when the application is shut down).A tracker is always running in a single thread. To balance the processing load over multiple threads create multiple trackers with the same name but different tracker id.
Trackers with different names will receive the same messages. Trackers with the same name will not. (Flux Capacitor will load balance between trackers with the same name).
Tracking stops if the provided message consumer throws an exception while handling messages (i.e. the tracker will need to be manually restarted in that case). However, if the tracker encounters an exception while fetching messages it will retry fetching indefinitely until this succeeds.
Trackers can choose a desired maximum batch size for consuming. By default this batch size will be the same as the batch size the tracker uses to fetch messages from Flux Capacitor. Each time the consumer has finished consuming a batch the tracker will update its position with Flux Capacitor.
Trackers can be configured to use batch interceptors. A batch interceptor manages the invocation of the message consumer. It is therefore typically used to manage a database transaction around the invocation of the consumer. Note that if the interceptor gives rise to an exception the tracker will be stopped.
-
-
Constructor Summary
Constructors Constructor Description DefaultTracker(String name, String trackerId, TrackingConfiguration configuration, Consumer<List<SerializedMessage>> consumer, TrackingClient trackingClient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()protected MessageBatchfetch(Long lastIndex)protected voidprocessAll(MessageBatch messageBatch)protected voidprocessPart(List<SerializedMessage> batch, int[] segment)voidrun()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.fluxcapacitor.common.Registration
merge
-
-
-
-
Constructor Detail
-
DefaultTracker
public DefaultTracker(String name, String trackerId, TrackingConfiguration configuration, Consumer<List<SerializedMessage>> consumer, TrackingClient trackingClient)
-
-
Method Detail
-
cancel
public void cancel()
- Specified by:
cancelin interfaceRegistration
-
fetch
protected MessageBatch fetch(Long lastIndex)
-
processAll
protected void processAll(MessageBatch messageBatch)
-
processPart
protected void processPart(List<SerializedMessage> batch, int[] segment)
-
-