Class MarkDeadlineManagerCallsInCallbacks

java.lang.Object
org.openrewrite.Recipe
org.axonframework.migration.MarkDeadlineManagerCallsInCallbacks
All Implemented Interfaces:
Cloneable

public class MarkDeadlineManagerCallsInCallbacks extends org.openrewrite.Recipe
Leaves a // TODO(axon4to5): marker on the Saga statements that use a DeadlineManager inside an asynchronous callback, which no longer works on the Axoniq Framework legacy module.

Axon Framework 4 offered one global DeadlineManager, so a Saga could schedule or cancel a deadline from any thread, for example once a command result arrived. The legacy module binds the DeadlineManager a Saga handler receives to that handler's processing context, and runs its calls when that context commits. A call from a callback that runs after the handler returned throws an IllegalStateException, which a whenComplete(..) callback or a Reactor subscriber drops, so the deadline is silently never scheduled or cancelled.

In a Saga, being a class with the Spring @Saga stereotype or a @SagaEventHandler method, the recipe marks each statement that:

  • passes a lambda, method reference or anonymous class that uses the DeadlineManager to a method of CompletionStage, such as whenComplete(..), or of a Reactor Mono or Flux;
  • ends a Reactor chain in subscribe(..) and passes the DeadlineManager on to another call in the arguments of one of the chain's operators, such as flatMap(helper(deadlineManager)).
Using the DeadlineManager means calling one of its methods, or passing it on to another method or constructor. The fix, waiting for the result inside the handler before calling the DeadlineManager, depends on the application, so the code is kept as is. The marker goes on the enclosing statement, so it lands above the chain holding the callback. Runs on the Axon Framework 4 DeadlineManager type, which the legacy module keeps in its package. Java sources only. Idempotent.
Since:
5.4.1
Author:
Stefan Dragisic
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.openrewrite.Recipe

    org.openrewrite.Recipe.Builder, org.openrewrite.Recipe.DelegatingRecipe
  • Field Summary

    Fields inherited from class org.openrewrite.Recipe

    contributors, examples, PANIC
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext>
     

    Methods inherited from class org.openrewrite.Recipe

    addDataTable, aggregateDataTableDescriptors, builder, buildRecipeList, causesAnotherCycle, clone, createRecipeDescriptor, equals, getContributors, getDataTableDescriptors, getDescriptor, getEstimatedEffortPerOccurrence, getExamples, getInstanceName, getInstanceNameSuffix, getJacksonPolymorphicTypeTag, getMaintainers, getName, getRecipeList, getTags, hashCode, maxCycles, noop, onComplete, run, run, run, setContributors, setExamples, validate, validate, validateAll, validateAll, withOptions

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MarkDeadlineManagerCallsInCallbacks

      public MarkDeadlineManagerCallsInCallbacks()
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in class org.openrewrite.Recipe
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in class org.openrewrite.Recipe
    • getVisitor

      public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()
      Overrides:
      getVisitor in class org.openrewrite.Recipe