Possibility to ensure that my Tracking Event Processor is up to date

Hi all
Is there a way to find out whether my Tracking Event Processor has processed all old events and is up to date?
So that I only call certain functions after everything is up to date.

Hi @Tino,

To address your query on determining whether your Tracking Event Processor has processed all old events and is up to date, we’ve developed a component that can help you ascertain this. Below is the Java code for the component:

@Component
public class CatchUpStateProvider {

    @Autowired
    private EventProcessingConfiguration eventProcessingConfiguration;

    public Map<String, Boolean> getProcessorStateMap() {
        Map<String, EventProcessor> processors = eventProcessingConfiguration.eventProcessors();

        return processors.values().stream()
                .filter(processor -> processor instanceof TrackingEventProcessor)
                .collect(Collectors.toMap(
                        EventProcessor::getName,
                        eventProcessor -> {
                            TrackingEventProcessor trackingProcessor = (TrackingEventProcessor) eventProcessor;
                            if (trackingProcessor.processingStatus() != null) {
                                return trackingProcessor.processingStatus().values().stream()
                                        .allMatch(EventTrackerStatus::isCaughtUp);
                            }
                            return false;
                        }));
    }
}

This component, CatchUpStateProvider, leverages the EventProcessingConfiguration to access all event processors. It then filters out those that are instances of TrackingEventProcessor. For each tracking event processor, it checks if the processor has caught up with all old events. This is determined by evaluating the processingStatus of each processor; specifically, it checks if all EventTrackerStatus instances within the processor’s status indicate that the processor is caught up.

The method getProcessorStateMap returns a map where each key is the name of a processor, and the corresponding value is a Boolean indicating whether that processor has caught up with all old events. This allows you to programmatically determine the readiness of your event processors and ensure that certain functions are called only after everything is up to date.

Feel free to integrate this component into your application to monitor the state of your tracking event processors efficiently.

Best regards :upside_down_face:,
Timo Frye

1 Like