/** * Besides committing {@link org.apache.kafka.clients.producer.KafkaProducer#commitTransaction} is also adding new * partitions to the transaction. flushNewPartitions method is moving this logic to pre-commit/flush, to make * resumeTransaction simpler. Otherwise resumeTransaction would require to restore state of the not yet added/"in-flight" * partitions. */ private void flushNewPartitions() { LOG.info("Flushing new partitions"); TransactionalRequestResult result = enqueueNewPartitions(); Object sender = getValue(kafkaProducer, "sender"); invoke(sender, "wakeup"); result.await(); }
/** * Besides committing {@link org.apache.kafka.clients.producer.KafkaProducer#commitTransaction} is also adding new * partitions to the transaction. flushNewPartitions method is moving this logic to pre-commit/flush, to make * resumeTransaction simpler. Otherwise resumeTransaction would require to restore state of the not yet added/"in-flight" * partitions. */ private void flushNewPartitions() { LOG.info("Flushing new partitions"); TransactionalRequestResult result = enqueueNewPartitions(); Object sender = getValue(kafkaProducer, "sender"); invoke(sender, "wakeup"); result.await(); }
/** * Besides committing {@link org.apache.kafka.clients.producer.KafkaProducer#commitTransaction} is also adding new * partitions to the transaction. flushNewPartitions method is moving this logic to pre-commit/flush, to make * resumeTransaction simpler. * Otherwise resumeTransaction would require to restore state of the not yet added/"in-flight" partitions. */ private void flushNewPartitions() { LOG.info("Flushing new partitions"); TransactionalRequestResult result = enqueueNewPartitions(); Object sender = getValue(kafkaProducer, "sender"); invoke(sender, "wakeup"); result.await(); }
/** * Aborts the ongoing transaction. Any unflushed produce messages will be aborted when this call is made. * This call will throw an exception immediately if any prior {@link #send(ProducerRecord)} calls failed with a * {@link ProducerFencedException} or an instance of {@link org.apache.kafka.common.errors.AuthorizationException}. * * @throws IllegalStateException if no transactional.id has been configured or no transaction has been started * @throws ProducerFencedException fatal error indicating another producer with the same transactional.id is active * @throws org.apache.kafka.common.errors.UnsupportedVersionException fatal error indicating the broker * does not support transactions (i.e. if its version is lower than 0.11.0.0) * @throws org.apache.kafka.common.errors.AuthorizationException fatal error indicating that the configured * transactional.id is not authorized. See the exception for more details * @throws KafkaException if the producer has encountered a previous fatal error or for any other unexpected error */ public void abortTransaction() throws ProducerFencedException { throwIfNoTransactionManager(); TransactionalRequestResult result = transactionManager.beginAbort(); sender.wakeup(); result.await(); }
/** * Commits the ongoing transaction. This method will flush any unsent records before actually committing the transaction. * * Further, if any of the {@link #send(ProducerRecord)} calls which were part of the transaction hit irrecoverable * errors, this method will throw the last received exception immediately and the transaction will not be committed. * So all {@link #send(ProducerRecord)} calls in a transaction must succeed in order for this method to succeed. * * @throws IllegalStateException if no transactional.id has been configured or no transaction has been started * @throws ProducerFencedException fatal error indicating another producer with the same transactional.id is active * @throws org.apache.kafka.common.errors.UnsupportedVersionException fatal error indicating the broker * does not support transactions (i.e. if its version is lower than 0.11.0.0) * @throws org.apache.kafka.common.errors.AuthorizationException fatal error indicating that the configured * transactional.id is not authorized. See the exception for more details * @throws KafkaException if the producer has encountered a previous fatal or abortable error, or for any * other unexpected error */ public void commitTransaction() throws ProducerFencedException { throwIfNoTransactionManager(); TransactionalRequestResult result = transactionManager.beginCommit(); sender.wakeup(); result.await(); }
TransactionalRequestResult result = transactionManager.sendOffsetsToTransaction(offsets, consumerGroupId); sender.wakeup(); result.await();
if (initTransactionsResult.await(maxBlockTimeMs, TimeUnit.MILLISECONDS)) { initTransactionsResult = null; } else {
commitResult.await();
/** * Besides committing {@link org.apache.kafka.clients.producer.KafkaProducer#commitTransaction} is also adding new * partitions to the transaction. flushNewPartitions method is moving this logic to pre-commit/flush, to make * resumeTransaction simpler. Otherwise resumeTransaction would require to restore state of the not yet added/"in-flight" * partitions. */ private void flushNewPartitions() { LOG.info("Flushing new partitions"); TransactionalRequestResult result = enqueueNewPartitions(); Object sender = getValue(kafkaProducer, "sender"); invoke(sender, "wakeup"); result.await(); }
/** * Besides committing {@link KafkaProducer#commitTransaction} is also adding new * partitions to the transaction. flushNewPartitions method is moving this logic to pre-commit/flush, to make * resumeTransaction simpler. Otherwise resumeTransaction would require to restore state of the not yet added/"in-flight" * partitions. */ private void flushNewPartitions() { LOG.info("Flushing new partitions"); TransactionalRequestResult result = enqueueNewPartitions(); Object sender = getValue(kafkaProducer, "sender"); invoke(sender, "wakeup"); result.await(); }
/** * Besides committing {@link org.apache.kafka.clients.producer.KafkaProducer#commitTransaction} is also adding new * partitions to the transaction. flushNewPartitions method is moving this logic to pre-commit/flush, to make * resumeTransaction simpler. Otherwise resumeTransaction would require to restore state of the not yet added/"in-flight" * partitions. */ private void flushNewPartitions() { LOG.info("Flushing new partitions"); TransactionalRequestResult result = enqueueNewPartitions(); Object sender = getValue(kafkaProducer, "sender"); invoke(sender, "wakeup"); result.await(); }
/** * Besides committing {@link org.apache.kafka.clients.producer.KafkaProducer#commitTransaction} is also adding new * partitions to the transaction. flushNewPartitions method is moving this logic to pre-commit/flush, to make * resumeTransaction simpler. * Otherwise resumeTransaction would require to restore state of the not yet added/"in-flight" partitions. */ private void flushNewPartitions() { LOG.info("Flushing new partitions"); TransactionalRequestResult result = enqueueNewPartitions(); Object sender = getValue(kafkaProducer, "sender"); invoke(sender, "wakeup"); result.await(); }