当前位置: 首页>>代码示例>>Java>>正文


Java TransactionalRequestResult.await方法代码示例

本文整理汇总了Java中org.apache.kafka.clients.producer.internals.TransactionalRequestResult.await方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionalRequestResult.await方法的具体用法?Java TransactionalRequestResult.await怎么用?Java TransactionalRequestResult.await使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.kafka.clients.producer.internals.TransactionalRequestResult的用法示例。


在下文中一共展示了TransactionalRequestResult.await方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: flushNewPartitions

import org.apache.kafka.clients.producer.internals.TransactionalRequestResult; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:FlinkKafkaProducer.java

示例2: initTransactions

import org.apache.kafka.clients.producer.internals.TransactionalRequestResult; //导入方法依赖的package包/类
/**
 * Needs to be called before any other methods when the transactional.id is set in the configuration.
 * <p>
 * This method does the following:
 * 1. Ensures any transactions initiated by previous instances of the producer
 * are completed. If the previous instance had failed with a transaction in
 * progress, it will be aborted. If the last transaction had begun completion,
 * but not yet finished, this method awaits its completion.
 * 2. Gets the internal producer id and epoch, used in all future transactional
 * messages issued by the producer.
 *
 * @throws IllegalStateException if the TransactionalId for the producer is not set
 *                               in the configuration.
 */
public void initTransactions() {
    if (transactionManager == null)
        throw new IllegalStateException("Cannot call initTransactions without setting a transactional id.");
    TransactionalRequestResult result = transactionManager.initializeTransactions();
    sender.wakeup();
    result.await();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:22,代码来源:KafkaProducer.java

示例3: sendOffsetsToTransaction

import org.apache.kafka.clients.producer.internals.TransactionalRequestResult; //导入方法依赖的package包/类
/**
 * Sends a list of consumed offsets to the consumer group coordinator, and also marks
 * those offsets as part of the current transaction. These offsets will be considered
 * consumed only if the transaction is committed successfully.
 * <p>
 * This method should be used when you need to batch consumed and produced messages
 * together, typically in a consume-transform-produce pattern.
 *
 * @throws ProducerFencedException if another producer with the same
 *                                 transactional.id is active.
 */
public void sendOffsetsToTransaction(Map<TopicPartition, OffsetAndMetadata> offsets,
                                     String consumerGroupId) throws ProducerFencedException {
    if (transactionManager == null)
        throw new IllegalStateException("Cannot send offsets to transaction since transactions are not enabled.");
    TransactionalRequestResult result = transactionManager.sendOffsetsToTransaction(offsets, consumerGroupId);
    sender.wakeup();
    result.await();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:20,代码来源:KafkaProducer.java

示例4: commitTransaction

import org.apache.kafka.clients.producer.internals.TransactionalRequestResult; //导入方法依赖的package包/类
/**
 * Commits the ongoing transaction. This method will flush any unsent records before actually committing the transaction.
 * <p>
 * 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 ProducerFencedException if another producer with the same
 *                                 transactional.id is active.
 */
public void commitTransaction() throws ProducerFencedException {
    if (transactionManager == null)
        throw new IllegalStateException("Cannot commit transaction since transactions are not enabled");
    TransactionalRequestResult result = transactionManager.beginCommit();
    sender.wakeup();
    result.await();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:18,代码来源:KafkaProducer.java

示例5: abortTransaction

import org.apache.kafka.clients.producer.internals.TransactionalRequestResult; //导入方法依赖的package包/类
/**
 * 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 ProducerFencedException if another producer with the same
 *                                 transactional.id is active.
 */
public void abortTransaction() throws ProducerFencedException {
    if (transactionManager == null)
        throw new IllegalStateException("Cannot abort transaction since transactions are not enabled.");
    TransactionalRequestResult result = transactionManager.beginAbort();
    sender.wakeup();
    result.await();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:16,代码来源:KafkaProducer.java


注:本文中的org.apache.kafka.clients.producer.internals.TransactionalRequestResult.await方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。