Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-6076

Using new producer api of transaction twice failed when server run on Windows OS

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 0.11.0.1
    • None
    • core

    Description

      Can't invoke twice (begin,commit transaction) on same Kafka Producer instance when it connected Kafka server run on windows 10.

      But same code can run successfully when Kafka server run on CentOS 7.3 64bit with same Kafka server code base and config.

      Producer code looks like:

      Map<String, Object> props = new HashMap<>();
      props.put("bootstrap.servers", "localhost:9092");
      props.put("transactional.id", "my-transactional-id");
      Producer<String, String> producer = new KafkaProducer<>(props, new StringSerializer(), new StringSerializer());
      producer.initTransactions();
      try

      { producer.beginTransaction(); for (int i = 0; i < 100; i++) producer.send(new ProducerRecord<>("test-2", Integer.toString(i), Integer.toString(i))); producer.commitTransaction(); System.out.println("sent one time done"); producer.beginTransaction(); for (int i = 0; i < 100; i++) producer.send(new ProducerRecord<>("test-2", Integer.toString(i), Integer.toString(i))); producer.commitTransaction(); System.out.println("sent two time done"); }

      catch (ProducerFencedException | OutOfOrderSequenceException | AuthorizationException e)

      { producer.close(); }

      catch (KafkaException e)

      { producer.abortTransaction(); }

      producer.close();

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              orwen Orwen Xiang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: