apache-kafka - psringboot 应用程序中的 KafkaProducer 事务
问题描述
我想在成功发送关于 kafka 主题的所有消息后执行一些代码。我读过很多文章。知道我们可以使用事务发送消息。
kafkaTemplate.executeInTransaction(operations -> {
for (String s : request) {
kafkaTemplate.send(new ProducerRecord<>(topic,key,s));
}
return null;
});
我尝试了这么短的代码,但不确定在成功执行此事务后如何执行某些代码。我也通过开始交易尝试了 kafkaProducer,但这也不适用于我的情况。如果有任何想法会有所帮助。
解决方案
Consumers must have
isolation.level=read_committed
to not see records until they are committed.There is no way to prevent a consumer from seeing a record that was sent outside of a transaction.
推荐阅读
- javascript - 如何在 ember 中为类属性编写 CSS Conditional?
- react-native - 如何在本机反应中发送客户端密钥和秘密进行身份验证
- google-apps-script - 发布 Google 表格插件
- ios - 在 iOS 中将错误日志消息解析为字符串
- javascript - Docker 代替 rvm、nvm 和所有其他
- google-apps-script - 如何将特定工作表中 A1 范围内的 URL 设置为变量?
- java - 为什么我的程序会跳过替换方法?
- jquery - 如何检测机器是否空闲,15 秒内没有来自服务器的值?
- sql - 谁禁用了 SQL Server 代理中的作业
- r - 如何在 dplyr 中使用“sql 函数”进行查询?