I have a service that handles kafka events. It publishes events to a topic then updates some attributes of that event in a db. I realized that in some cases, streambridge.send will return true, thought the event was never published, which will result in the new attributes being set. I.e a Not authorized to access topics exception. How can I reliably ensure events are published to Kafka using Streambridge, preventing data inconsistencies when exceptions occur?
Wondering, if there is way to return false as part of that operation or a way to handle the asynchronous failure since it happens after streambridge.send which I read does not guarantee delivery to the topic.
Would configuring ack=1 force streambridge to wait until receiption of the message?
Boolean Sent=Streambridge.send(name, dbmessage)
If(!sent){
Throw new runtimeException(“failed to send”)}
dbmessage.setSent(true)