Java Code Examples for org.apache.flink.streaming.connectors.kafka.internal.FlinkKafkaInternalProducer#getProducerId()
The following examples show how to use
org.apache.flink.streaming.connectors.kafka.internal.FlinkKafkaInternalProducer#getProducerId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlinkKafkaInternalProducerITCase.java From flink with Apache License 2.0 | 5 votes |
@Test(timeout = 30000L) public void testResumeTransaction() throws IOException { String topicName = "flink-kafka-producer-resume-transaction"; FlinkKafkaInternalProducer<String, String> kafkaProducer = new FlinkKafkaInternalProducer<>(extraProperties); try { kafkaProducer.initTransactions(); kafkaProducer.beginTransaction(); kafkaProducer.send(new ProducerRecord<>(topicName, "42", "42")); kafkaProducer.flush(); long producerId = kafkaProducer.getProducerId(); short epoch = kafkaProducer.getEpoch(); FlinkKafkaInternalProducer<String, String> resumeProducer = new FlinkKafkaInternalProducer<>(extraProperties); try { resumeProducer.resumeTransaction(producerId, epoch); resumeProducer.commitTransaction(); } finally { resumeProducer.close(Duration.ofSeconds(5)); } assertRecord(topicName, "42", "42"); // this shouldn't throw - in case of network split, old producer might attempt to commit it's transaction kafkaProducer.commitTransaction(); // this shouldn't fail also, for same reason as above resumeProducer = new FlinkKafkaInternalProducer<>(extraProperties); try { resumeProducer.resumeTransaction(producerId, epoch); resumeProducer.commitTransaction(); } finally { resumeProducer.close(Duration.ofSeconds(5)); } } finally { kafkaProducer.close(Duration.ofSeconds(5)); } deleteTestTopic(topicName); }
Example 2
Source File: FlinkKafkaProducer.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
KafkaTransactionState(String transactionalId, FlinkKafkaInternalProducer<byte[], byte[]> producer) { this(transactionalId, producer.getProducerId(), producer.getEpoch(), producer); }
Example 3
Source File: FlinkKafkaProducer.java From flink with Apache License 2.0 | 4 votes |
KafkaTransactionState(String transactionalId, FlinkKafkaInternalProducer<byte[], byte[]> producer) { this(transactionalId, producer.getProducerId(), producer.getEpoch(), producer); }
Example 4
Source File: FlinkKafkaProducer.java From flink with Apache License 2.0 | 4 votes |
@VisibleForTesting public KafkaTransactionState(String transactionalId, FlinkKafkaInternalProducer<byte[], byte[]> producer) { this(transactionalId, producer.getProducerId(), producer.getEpoch(), producer); }