Class AsyncRetryScheduler
- All Implemented Interfaces:
DescribableComponent,RetryScheduler
ScheduledExecutorService based on a given
policy.- Author:
- Allard Buijze
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.messaging.core.retry.RetryScheduler
RetryScheduler.Dispatcher<M extends Message,R extends Message> -
Constructor Summary
ConstructorsConstructorDescriptionAsyncRetryScheduler(RetryPolicy retryPolicy, ScheduledExecutorService executor) Initialize the retry scheduler using givenretryPolicyand execute retries on givenexecutor. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.<M extends Message,R extends Message>
MessageStream<R> scheduleRetry(M message, ProcessingContext processingContext, Throwable cause, RetryScheduler.Dispatcher<M, R> dispatcher) Schedules the givenmessageto retry dispatching using the givendispatchingfunction.
-
Constructor Details
-
AsyncRetryScheduler
Initialize the retry scheduler using givenretryPolicyand execute retries on givenexecutor.This implementation will schedule retry tasks in memory.
- Parameters:
retryPolicy- The policy indicating if and when to perform retriesexecutor- The executor service on which retries are scheduled
-
-
Method Details
-
scheduleRetry
public <M extends Message,R extends Message> MessageStream<R> scheduleRetry(@Nonnull M message, @Nullable ProcessingContext processingContext, @Nonnull Throwable cause, @Nonnull RetryScheduler.Dispatcher<M, R> dispatcher) Description copied from interface:RetrySchedulerSchedules the givenmessageto retry dispatching using the givendispatchingfunction.Implementations may execute the retries immediately or schedule them later retry. The returned
MessageStreammay complete after several retry attempts or immediately, depending on whether retries are configured or if the cause indicates that a retry could possibly provide a different outcome.If the scheduler determines that a retry can not lead to a different outcome, it must return immediately with a failed
MessageStreamholding the original givencauseas its failure.- Specified by:
scheduleRetryin interfaceRetryScheduler- Type Parameters:
M- The type of message to (re)dispatchR- The type of message expected as a result of dispatching- Parameters:
message- The Message being dispatchedprocessingContext- The context under which the message is dispatchedcause- The cause of the failure.dispatcher- The function to execute individual retries- Returns:
- a MessageStream representing the result of the last attempt
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.Best Practices: As a general rule, all relevant fields of a
DescribableComponentimplementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing thedescribeTomethod, who should focus on providing information that is useful for understanding the component's configuration and state.Example implementation:
public void describeTo(ComponentDescriptor descriptor) { descriptor.describeProperty("name", this.name); descriptor.describeProperty("enabled", this.enabled); descriptor.describeProperty("configuration", this.configuration); // A nested component descriptor.describeProperty("handlers", this.eventHandlers); // A collection }- Specified by:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-