1
votes

I use Spring cloud stream with kafka stream to do some processing and somewhere in the middle of the processing I need to save the intermediate result to DB via Hibernate (Spring data jpa).

1.Should the data base call be async and to continue with the stream processing? 2. regardless of calling db sync or asyc how to handle error? say for example I doing some query in the middle of the (kafka stream) process and exception in thrown so rollback to db transaction occurs, can I aslo make "revert" the message that cause the exception in the middle of the process and try again? or is there any pattern that deals with it?

I believe Enterprise Integration Patterns is what you are looking for (enterpriseintegrationpatterns.com/patterns/messaging) - Kafka being a MessageBroker for the pattern - blurfus
This is not a technical question, rather business. You can do all kinds of things during errors. The real question is what is your business requirement? What are your users asking for? What do they expect? - Oleg Zhurakousky