Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleKafkaProducer
     /**
     * If {@link #flush()} isThis method should only be called explicitlyif beforethere thisare methodno andpending the input config parameter determines ignoring errors,writes, i.e., only after calling {@link #flush()}.
     * this method clears the last exception produced by the {@link #send(ProducerRecord)} call and transits the transaction If there are any errors in sending messages to topics, these errors can be cleared by passing {@link CommitOption#CLEAR_SEND_ERRORS},
     * allowing the transaction to be committed even in case of data loss.
     * <p>
 out  of error state.* Thereupon,If thethis method carries out the same procedures as delineated in {@link #commitTransaction()}is used while there are pending sends, the send errors cannot be cleared.
     *  
     * @param commitOption The method option
     *
     * @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 org.apache.kafka.common.errors.InvalidProducerEpochException if the producer has attempted to produce with an old epoch
     *         to the partition leader. 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
     * @throws TimeoutException if the time taken for committing the transaction has surpassed <code>max.block.ms</code>.
     * @throws InterruptException if the thread is interrupted while blocked
     */


     public void commitTransaction(CommitOption option) throws ProducerFencedException {}

     public enum CommitOption {
        /**
         * Commits the ongoing transaction, flushing any unsent records before actually committing
         * the transaction. If any of the records sent in this transaction hit unrecoverable errors,
         * the transaction will not be committed.
         */
        NONE,
        /**
         * Commits the ongoing transaction, first clearing any errors from records already sent in
         * this transaction. If there are any unsent records flushed by this operation which hit 
         * unrecoverable errors, these errors will not be cleared and the transaction will not be 
         * committed.
         * <p>
         * To ensure there are no unsent records, you must call {@link #flush()} before
         * committing the transaction.
         */
        CLEAR_SEND_ERRORS
    }

...