Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrderCreate Event Publishing maybe Failure - Transaction State Inconsistency #125

Open
dragonlage opened this issue Feb 27, 2025 · 0 comments

Comments

@dragonlage
Copy link

The order creation process is saving orders to the database in a PENDING state, but the event publishing (using the Outbox Pattern) is happening asynchronously and outside of the transaction. This introduces a risk where events may fail to be published, leading to an inconsistency between the order state and the event state, causing potential data integrity issues. Actually am not found sync publish method. and async publish method is swallow exception. Just want to know how can i handle this scenario. because eventual.io already use outbox pattern i don't want use retry maybe in my application code

@Transactional public Order createOrder(OrderDetails orderDetails) { ResultWithEvents<Order> orderWithEvents = Order.createOrder(orderDetails); Order order = orderWithEvents.result; orderRepository.save(order); domainEventPublisher.publish(Order.class, order.getId(), orderWithEvents.events); return order; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant