Hello,

I was testing the transactional message on kafka.
but I get a problem.
the producer always blocking at second commitTransaction.
Here is my code:

        Properties kafkaProps = new Properties();
        kafkaProps.setProperty("bootstrap.servers", "localhost:9092");
kafkaProps.setProperty("key.serializer", LongSerializer.class.getName()); kafkaProps.setProperty("value.serializer", StringSerializer.class.getName());
        kafkaProps.setProperty("transactional.id", "hello");
try (KafkaProducer<Long, String> producer = new KafkaProducer<>(kafkaProps)) {
            producer.initTransactions();
            producer.beginTransaction();
ProducerRecord<Long, String> record = new ProducerRecord<>("test", 0, (long) 0, Long.toString(0));
            producer.send(record);
            producer.sendOffsetsToTransaction(new HashMap<>(), "");
            producer.commitTransaction();
            producer.beginTransaction();
record = new ProducerRecord<>("test", 0, (long)0, Long.toString(0));
            producer.send(record);
            producer.commitTransaction(); // blocking here
        }

Enviroment:
Kafka broker: 1.0.0
broker count: 1
Kafka Client: 1.0.0
and I use the default server.properties in config/

broker.id=0
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/tmp/kafka-logs
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=localhost:2181
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0

I have run the program in Windows 7 and CentOS 6.9.
but it blocking in the second commitTransaction.


Reply via email to