/** * Initialize a configuration for a Saga of given {@code sagaType}, using a Tracking Event Processor (with provided * name) to process incoming Events from a Message Source provided by given {@code messageSourceBuilder}. Note that * a Token Store should be configured in the global configuration, or the Saga Manager will default to an in-memory * token store, which is not recommended for production environments. * * @param sagaType The type of Saga to handle events with * @param processingGroup The name of the processing group to be used for this saga * @param messageSourceBuilder The function providing the message source based on the configuration * @param <S> The type of Saga configured in this configuration * @return a SagaConfiguration instance, ready for further configuration */ public static <S> SagaConfiguration<S> trackingSagaManager(Class<S> sagaType, String processingGroup, Function<Configuration, StreamableMessageSource<TrackedEventMessage<?>>> messageSourceBuilder) { ProcessorInfo processorInfo = new ProcessorInfo(false, ProcessorInfo.ProcessorType.TRACKING, processingGroup); return new SagaConfiguration<>(sagaType, processorInfo, TrackingEventProcessor.class, messageSourceBuilder, c -> null, c -> null); }
/** * Initialize a configuration for a Saga of given {@code sagaType}, using a Subscribing Event Processor (with * provided name) to process incoming Events from the message source provided by given {@code * messageSourceBuilder}. * <p> * This method allows a custom {@link EventProcessingStrategy} to be provided, in case handlers shouldn't be * invoked in the thread that delivers the message. * * @param sagaType The type of Saga to handle events with * @param processingGroup The name of the processing group to be used for this saga * @param messageSourceBuilder The function providing the message source based on the configuration * @param eventProcessingStrategy The strategy to use to invoke the event handlers. * @param <S> The type of Saga configured in this configuration * @return a SagaConfiguration instance, ready for further configuration */ public static <S> SagaConfiguration<S> subscribingSagaManager( Class<S> sagaType, String processingGroup, Function<Configuration, SubscribableMessageSource<EventMessage<?>>> messageSourceBuilder, Function<Configuration, EventProcessingStrategy> eventProcessingStrategy) { ProcessorInfo processorInfo = new ProcessorInfo(false, ProcessorInfo.ProcessorType.SUBSCRIBING, processingGroup); return new SagaConfiguration<>(sagaType, processorInfo, SubscribingEventProcessor.class, c -> null, messageSourceBuilder, eventProcessingStrategy); }
/** * Initialize a configuration for a Saga of given {@code sagaType}, using a Tracking Event Processor to process * incoming Events from a Message Source provided by given {@code messageSourceBuilder}. Note that a Token Store * should be configured in the global configuration, or the Saga Manager will default to an in-memory token store, * which is not recommended for production environments. * * @param sagaType The type of Saga to handle events with * @param messageSourceBuilder The function providing the message source based on the configuration * @param <S> The type of Saga configured in this configuration * @return a SagaConfiguration instance, ready for further configuration */ public static <S> SagaConfiguration<S> trackingSagaManager( Class<S> sagaType, Function<Configuration, StreamableMessageSource<TrackedEventMessage<?>>> messageSourceBuilder) { ProcessorInfo processorInfo = new ProcessorInfo(true, ProcessorInfo.ProcessorType.TRACKING, processingGroupName(sagaType)); return new SagaConfiguration<>(sagaType, processorInfo, TrackingEventProcessor.class, messageSourceBuilder, c -> null, c -> null); }
/** * Initialize a configuration for a Saga of given {@code sagaType}, using a Subscribing Event Processor to process * incoming Events from the message source provided by given {@code messageSourceBuilder}. * <p> * This methods allows a custom {@link EventProcessingStrategy} to be provided, in case handlers shouldn't be * invoked in the thread that delivers the message. * * @param sagaType The type of Saga to handle events with * @param messageSourceBuilder The function providing the message source based on the configuration * @param eventProcessingStrategy The strategy to use to invoke the event handlers. * @param <S> The type of Saga configured in this configuration * @return a SagaConfiguration instance, ready for further configuration */ public static <S> SagaConfiguration<S> subscribingSagaManager( Class<S> sagaType, Function<Configuration, SubscribableMessageSource<EventMessage<?>>> messageSourceBuilder, Function<Configuration, EventProcessingStrategy> eventProcessingStrategy) { ProcessorInfo processorInfo = new ProcessorInfo(true, ProcessorInfo.ProcessorType.SUBSCRIBING, processingGroupName(sagaType)); return new SagaConfiguration<>(sagaType, processorInfo, SubscribingEventProcessor.class, c -> null, messageSourceBuilder, eventProcessingStrategy); }