eventuate-tram / eventuate-tram-sagas

Sagas for microservices
Other
994 stars 225 forks source link

Eventuate sagas not well described #17

Open yami12376 opened 4 years ago

yami12376 commented 4 years ago

I tried to start basic saga - but i did not find how to start it. In documentation: https://eventuate.io/docs/manual/eventuate-tram/latest/getting-started-eventuate-tram-sagas.html#getting-started-tram-sagas

I see:

Creating an saga orchestrator

The OrderService creates the saga:

public class OrderService {

@Autowired private SagaManager createOrderSagaManager;

@Autowired private OrderRepository orderRepository;

@Transactional public Order createOrder(OrderDetails orderDetails) { ResultWithEvents oe = Order.createOrder(orderDetails); Order order = oe.result; orderRepository.save(order); CreateOrderSagaData data = new CreateOrderSagaData(order.getId(), orderDetails); createOrderSagaManager.create(data, Order.class, order.getId()); return order; } }

But i only wanted to create saga, so i need to use createOrderSagaManager.create(data); ? Why it is not described in documentation? I am wondering what this code actually do - i can not find any information in the documentation. Can i start Saga with passing some DTO wihout these lines:

ResultWithEvents<Order> oe = Order.createOrder(orderDetails);
Order order = oe.result;
orderRepository.save(order);

? Can you add video when you tell how this framework work line by line?

And this: @Autowired private SagaManager<CreateOrderSagaData> createOrderSagaManager;

From where is this createOrderSagaManager injected?

isfong commented 3 years ago

Hi~! There should be a @Configuration class configured with this @Bean, You may need to use SagaInstanceFactory , It is more intuitive.

this.sagaInstanceFactory.create( this.bizSaga, new BizSagaData( required biz params...));