Class MigrateDeadlineManagerBuilders

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

public class MigrateDeadlineManagerBuilders extends org.openrewrite.Recipe
Migrates the builder calls of the Axon Framework 4 deadline managers to the builders of the Axoniq Framework legacy module.

The legacy SimpleDeadlineManager, QuartzDeadlineManager, JobRunrDeadlineManager and DbSchedulerDeadlineManager keep their Axon Framework 4 builders, except for three parameters that have no Axon Framework 5 counterpart:

  • spanFactory(..) is removed, as tracing comes from a decorator around every configured DeadlineManager;
  • transactionManager(..) is removed, as a fired deadline runs in a unit of work from the required unitOfWorkFactory(..), which provides the transaction;
  • serializer(..) is replaced by the required converter(..) on the three persistent managers.
The recipe removes the first two calls, and replaces serializer(..) with converter(..) when the serializer is a default JacksonSerializer, whose stored deadlines a default JacksonConverter reads. A serializer that a Spring @Bean method receives as a parameter used for nothing else becomes the converter Axon Framework 5 Spring Boot provides in its place: the "eventSerializer" qualifier an EventConverter, "messageSerializer" a MessageConverter, and "serializer" or no qualifier a GeneralConverter, the one converter type Spring resolves without ambiguity. Which serializer that parameter was is configured elsewhere, so that statement keeps a marker to check the converter against the deadlines already stored.

It inserts unitOfWorkFactory(..) right after builder() in a Java builder chain when a factory is in reach: configuration.getComponent(UnitOfWorkFactory.class) on an Axon Framework 4 Configuration lambda parameter, method parameter or preceding local, which Axon Framework 5's Configuration answers too, or, in a Spring @Bean method, a UnitOfWorkFactory parameter it adds to the method, which Spring resolves from the Axon configuration.

Which UnitOfWorkFactory to use elsewhere, and which converter reads what any other serializer stored, cannot be inferred at the call site, so the recipe leaves a // TODO(axon4to5): marker on the statement that builds the manager for those. Builder calls of other components with the same method names are left alone. The recipe is idempotent: a statement that already carries a marker is not marked again.

Since:
5.4.0
Author:
Mateusz Nowak
  • 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

    • MigrateDeadlineManagerBuilders

      public MigrateDeadlineManagerBuilders()
  • 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