diff --git a/eventuate-tram-sagas-participant/src/main/java/io/eventuate/tram/sagas/participant/SagaCommandDispatcherFactory.java b/eventuate-tram-sagas-participant/src/main/java/io/eventuate/tram/sagas/participant/SagaCommandDispatcherFactory.java index 4642753..8b5e20b 100644 --- a/eventuate-tram-sagas-participant/src/main/java/io/eventuate/tram/sagas/participant/SagaCommandDispatcherFactory.java +++ b/eventuate-tram-sagas-participant/src/main/java/io/eventuate/tram/sagas/participant/SagaCommandDispatcherFactory.java @@ -24,6 +24,8 @@ public SagaCommandDispatcherFactory(MessageConsumer messageConsumer, } public SagaCommandDispatcher make(String commandDispatcherId, CommandHandlers target) { - return new SagaCommandDispatcher(commandDispatcherId, target, messageConsumer, sagaLockManager, commandNameMapping, commandReplyProducer); + SagaCommandDispatcher sagaCommandDispatcher = new SagaCommandDispatcher(commandDispatcherId, target, messageConsumer, sagaLockManager, commandNameMapping, commandReplyProducer); + sagaCommandDispatcher.initialize(); + return sagaCommandDispatcher; } } diff --git a/eventuate-tram-sagas-reactive-participant/src/main/java/io/eventuate/tram/sagas/reactive/participant/ReactiveSagaCommandDispatcherFactory.java b/eventuate-tram-sagas-reactive-participant/src/main/java/io/eventuate/tram/sagas/reactive/participant/ReactiveSagaCommandDispatcherFactory.java index 6c9c8e6..1989b33 100644 --- a/eventuate-tram-sagas-reactive-participant/src/main/java/io/eventuate/tram/sagas/reactive/participant/ReactiveSagaCommandDispatcherFactory.java +++ b/eventuate-tram-sagas-reactive-participant/src/main/java/io/eventuate/tram/sagas/reactive/participant/ReactiveSagaCommandDispatcherFactory.java @@ -18,6 +18,8 @@ public ReactiveSagaCommandDispatcherFactory(ReactiveMessageConsumer messageConsu } public ReactiveSagaCommandDispatcher make(String commandDispatcherId, ReactiveCommandHandlers target) { - return new ReactiveSagaCommandDispatcher(commandDispatcherId, target, messageConsumer, sagaLockManager, commandReplyProducer); + ReactiveSagaCommandDispatcher reactiveSagaCommandDispatcher = new ReactiveSagaCommandDispatcher(commandDispatcherId, target, messageConsumer, sagaLockManager, commandReplyProducer); + reactiveSagaCommandDispatcher.initialize(); + return reactiveSagaCommandDispatcher; } } diff --git a/orders-and-customers-spring-reactive/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/reactive/customers/CustomerConfiguration.java b/orders-and-customers-spring-reactive/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/reactive/customers/CustomerConfiguration.java index 8be3faa..59bd73f 100644 --- a/orders-and-customers-spring-reactive/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/reactive/customers/CustomerConfiguration.java +++ b/orders-and-customers-spring-reactive/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/reactive/customers/CustomerConfiguration.java @@ -7,11 +7,8 @@ import io.eventuate.tram.reactive.commands.consumer.ReactiveCommandDispatcher; import io.eventuate.tram.sagas.reactive.participant.ReactiveSagaCommandDispatcherFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories; import org.springframework.transaction.reactive.TransactionalOperator; @Configuration @@ -30,7 +27,7 @@ public CustomerCommandHandler customerCommandHandler(CustomerService customerSer return new CustomerCommandHandler(customerService); } - @Bean(initMethod = "initialize") + @Bean public ReactiveCommandDispatcher consumerCommandDispatcher(CustomerCommandHandler target, ReactiveSagaCommandDispatcherFactory sagaCommandDispatcherFactory) { diff --git a/orders-and-customers-spring/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/customers/CustomerConfiguration.java b/orders-and-customers-spring/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/customers/CustomerConfiguration.java index 2dabaab..c76a410 100644 --- a/orders-and-customers-spring/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/customers/CustomerConfiguration.java +++ b/orders-and-customers-spring/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/customers/CustomerConfiguration.java @@ -4,9 +4,7 @@ import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.service.CustomerCommandHandler; import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.service.CustomerService; import io.eventuate.tram.commands.consumer.CommandDispatcher; -import io.eventuate.tram.sagas.common.SagaLockManager; import io.eventuate.tram.sagas.participant.SagaCommandDispatcherFactory; -import io.eventuate.tram.sagas.spring.participant.SagaParticipantConfiguration; import io.eventuate.tram.spring.optimisticlocking.OptimisticLockingDecoratorConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -36,9 +34,9 @@ public CustomerCommandHandler customerCommandHandler(CustomerDao customerDao) { // TODO Exception handler for CustomerCreditLimitExceededException - @Bean(initMethod = "initialize") + @Bean public CommandDispatcher consumerCommandDispatcher(CustomerCommandHandler target, - SagaLockManager sagaLockManager, SagaCommandDispatcherFactory sagaCommandDispatcherFactory) { + SagaCommandDispatcherFactory sagaCommandDispatcherFactory) { return sagaCommandDispatcherFactory.make("customerCommandDispatcher", target.commandHandlerDefinitions()); } diff --git a/orders-and-customers-spring/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/orders/OrderConfiguration.java b/orders-and-customers-spring/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/orders/OrderConfiguration.java index 23e6f76..76d036e 100644 --- a/orders-and-customers-spring/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/orders/OrderConfiguration.java +++ b/orders-and-customers-spring/src/main/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/orders/OrderConfiguration.java @@ -68,7 +68,7 @@ public OrderCommandHandler orderCommandHandler(OrderDao orderDao) { return new OrderCommandHandler(orderDao); } - @Bean(initMethod = "initialize") + @Bean public CommandDispatcher orderCommandDispatcher(OrderCommandHandler target, SagaCommandDispatcherFactory sagaCommandDispatcherFactory) { return sagaCommandDispatcherFactory.make("orderCommandDispatcher", target.commandHandlerDefinitions()); } diff --git a/orders-and-customers-spring/src/test/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/integrationtests/OrdersAndCustomersIntegrationCommonIntegrationTestConfiguration.java b/orders-and-customers-spring/src/test/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/integrationtests/OrdersAndCustomersIntegrationCommonIntegrationTestConfiguration.java index a710f97..1d68dad 100644 --- a/orders-and-customers-spring/src/test/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/integrationtests/OrdersAndCustomersIntegrationCommonIntegrationTestConfiguration.java +++ b/orders-and-customers-spring/src/test/java/io/eventuate/examples/tram/sagas/ordersandcustomers/spring/integrationtests/OrdersAndCustomersIntegrationCommonIntegrationTestConfiguration.java @@ -3,14 +3,14 @@ import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.sagas.createorder.CreateOrderSaga; import io.eventuate.examples.tram.sagas.ordersandcustomers.spring.customers.CustomerConfiguration; import io.eventuate.examples.tram.sagas.ordersandcustomers.spring.orders.OrderConfiguration; -import io.eventuate.tram.spring.commands.producer.TramCommandProducerConfiguration; -import io.eventuate.tram.spring.events.publisher.TramEventsPublisherConfiguration; -import io.eventuate.tram.spring.events.subscriber.TramEventSubscriberConfiguration; import io.eventuate.tram.events.subscriber.DomainEventDispatcher; import io.eventuate.tram.events.subscriber.DomainEventDispatcherFactory; import io.eventuate.tram.messaging.common.ChannelMapping; import io.eventuate.tram.messaging.common.DefaultChannelMapping; import io.eventuate.tram.sagas.spring.orchestration.SagaOrchestratorConfiguration; +import io.eventuate.tram.spring.commands.producer.TramCommandProducerConfiguration; +import io.eventuate.tram.spring.events.publisher.TramEventsPublisherConfiguration; +import io.eventuate.tram.spring.events.subscriber.TramEventSubscriberConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -51,7 +51,7 @@ public SagaEventsConsumer sagaEventsConsumer() { return new SagaEventsConsumer(); } - @Bean(initMethod = "initialize") + @Bean public DomainEventDispatcher domainEventDispatcher(TramCommandsAndEventsIntegrationData tramCommandsAndEventsIntegrationData, SagaEventsConsumer sagaEventsConsumer, DomainEventDispatcherFactory domainEventDispatcherFactory) { return domainEventDispatcherFactory.make(tramCommandsAndEventsIntegrationData.getEventDispatcherId(), sagaEventsConsumer.domainEventHandlers()); }