@Test void testTransactionalProducerBehaviorOnCommittingAnAbortedTransaction() { assumeFalse( System.getProperty("os.name").contains("Windows"), "Transactional producers not supported on Windows" ); ProducerFactory<String, String> producerFactory = transactionalProducerFactory(kafkaBroker, "xyz"); Producer<String, String> testProducer = producerFactory.createProducer(); try { testProducer.beginTransaction(); send(testProducer, "testTransactionalProducerBehaviorOnCommittingAnAbortedTransaction", "bar"); testProducer.abortTransaction(); assertThrows(KafkaException.class, testProducer::commitTransaction); } finally { cleanup(producerFactory, testProducer); } }
@Override public Producer<K, V> createProducer() { if (confirmationMode.isTransactional()) { return createTransactionalProducer(); } if (this.nonTransactionalProducer == null) { synchronized (this) { if (this.nonTransactionalProducer == null) { this.nonTransactionalProducer = new ShareableProducer<>(createKafkaProducer(configuration)); } } } return this.nonTransactionalProducer; }
DefaultProducerFactory implements ProducerFactory<K, V> { @Override public Producer<K, V> createProducer() { if (confirmationMode.isTransactional()) { return createTransactionalProducer(); } if (this.nonTransactionalProducer == null) { synchronized (this) { if (this.nonTransactionalProducer == null) { this.nonTransactionalProducer = new ShareableProducer<>(createKafkaProducer(configuration)); } } } return this.nonTransactionalProducer; } }
DefaultProducerFactory implements ProducerFactory<K, V> { @Override public Producer<K, V> createProducer() { if (confirmationMode.isTransactional()) { return createTransactionalProducer(); } if (this.nonTransactionalProducer == null) { synchronized (this) { if (this.nonTransactionalProducer == null) { this.nonTransactionalProducer = new ShareableProducer<>(createKafkaProducer(configuration)); } } } return this.nonTransactionalProducer; } @SuppressWarnings("WeakerAccess") protected  DefaultProducerFactory(Builder<K, V> builder); }
DefaultProducerFactory implements ProducerFactory<K, V> { @Override public Producer<K, V> createProducer() { if (confirmationMode.isTransactional()) { return createTransactionalProducer(); } if (this.nonTransactionalProducer == null) { synchronized (this) { if (this.nonTransactionalProducer == null) { this.nonTransactionalProducer = new ShareableProducer<>(createKafkaProducer(configuration)); } } } return this.nonTransactionalProducer; } @SuppressWarnings("WeakerAccess") protected  DefaultProducerFactory(Builder<K, V> builder); static Builder<K, V> builder(); @Override Producer<K, V> createProducer(); @Override ConfirmationMode confirmationMode(); Map<String, Object> configurationProperties(); String transactionIdPrefix(); @Override void shutDown(); }
DefaultProducerFactory implements ProducerFactory<K, V> { @Override public Producer<K, V> createProducer() { if (confirmationMode.isTransactional()) { return createTransactionalProducer(); } if (this.nonTransactionalProducer == null) { synchronized (this) { if (this.nonTransactionalProducer == null) { this.nonTransactionalProducer = new ShareableProducer<>(createKafkaProducer(configuration)); } } } return this.nonTransactionalProducer; } @SuppressWarnings("WeakerAccess") protected  DefaultProducerFactory(Builder<K, V> builder); static Builder<K, V> builder(); @Override Producer<K, V> createProducer(); @Override ConfirmationMode confirmationMode(); Map<String, Object> configurationProperties(); String transactionIdPrefix(); @Override void shutDown();  }