Pausing event processor via API

I’m looking at implementing a programmatic reset handler for an event processor. There doesn’t seem to be much documentation around reset handlers in the Reference Guide, but the guidance from the trainings was to pause all of the event processors first, then have one of them reset the token, then resume them all.

Looking at the Swagger doc, the API requires that you specify a component in order to get the list of processors and/or pause them. But I don’t see anything indicating what the component should be, and there doesn’t appear to be any GET request that lists what components exist. Is there a way to find what the components for my event processors should be?

Hi Jesse,

You can find an example in lab 6 of the training material (the ManagementEndpoint). The processor name is the same as the name of the processing group annotation of the event handler. If there is no processing group annotation the fully qualified class name of the event handler class must be used.

Best,

Yvonne

Hi @jesse.docken, just to give you some “code”, that’s what I am used to do.

  • Implement an endpoint which accepts the processingGroup as a parameter (usually as a DELETE operation);
  • Make sure this endpoint is somehow secured :wink:

That’s how my implementation would look like:

private final Configuration configuration; // constructor injected

public void triggerResetEventEndpointFor(String processingGroup) {
	Assert.hasLength(processingGroup, "Processing Group is mandatory and can't be empty!");

	configuration.eventProcessingConfiguration()
				 .eventProcessorByProcessingGroup(processingGroup,
												  StreamingEventProcessor.class)
				 .ifPresent(streamingEventProcessor -> {
					 if (streamingEventProcessor.supportsReset()) {
						 logger.info("Triggering ResetTriggeredEvent for processingGroup {}", processingGroup);
						 streamingEventProcessor.shutDown();
						 streamingEventProcessor.resetTokens();
						 streamingEventProcessor.start();
					 }
				 });
}

Hope it helps further!

KR,

So this would be a microservice that I’d be scaling up horizontally, and according to the training materials when you have multiple services registering the same event processor you can pause them all simultaneously via the API. I was looking to make it so that the application could call Axon Server to pause all event processors of the given type, then drive the reset, and then resume the processors via API again, but there’s no documentation for using those APIs. I found them in Swagger, but it doesn’t explain what the component should be.

Am I misunderstanding the use for these APIs, or how event processing replay would work with multiple instances of the same codebase?

Hi @jesse.docken,

We took some time to provide a code-sample about what we talked here.
Hope it will help not only to clarify things but to move you forward.

The code sample we worked on can be found here: code-samples/reset-handler at master · AxonIQ/code-samples · GitHub

It shows how to do a reset using only AF but also using AS APIs (as you mentioned).
Any feedback or improvement, please let us know.

KR,