JDBC事务和kafka事务可以作为XA事务一起工作吗?kafka事务API支持XA事务吗?
我的 kafka 生产者抛出错误“尝试从状态 IN_TRANSACTION 到状态 IN_TRANSACTION 的无效转换”。这是我正在努力实现的目标 -
KafkaProducer producer = new KafkaProducer<>(props);
producer.initTransactions();
//transaction 1
producer.beginTransaction();
//send some messages
producer.commitTransaction();
//transaction 2
producer.beginTransaction(); //here it throws an exception "Invalid transition attempted from state IN_TRANSACTION to state IN_TRANSACTION".
//send some messages
producer.commitTransaction();
producer.close();
Run Code Online (Sandbox Code Playgroud)
如果我producer.initTransactions();在开始事务 2 之前再次调用,它会抛出异常“尝试从状态 READY 到状态 INITIALIZING 的无效转换”。
我究竟做错了什么?