Java Code Examples for org.apache.flink.streaming.connectors.kafka.internal.FlinkKafkaProducer#close()

The following examples show how to use org.apache.flink.streaming.connectors.kafka.internal.FlinkKafkaProducer#close() . 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: FlinkKafkaProducerITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 30000L, expected = IllegalStateException.class)
public void testBeginTransactionAfterClosed() {
	FlinkKafkaProducer<String, String> kafkaProducer = new FlinkKafkaProducer<>(extraProperties);
	kafkaProducer.initTransactions();
	kafkaProducer.close();
	kafkaProducer.beginTransaction();
}
 
Example 2
Source File: FlinkKafkaProducerITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
private FlinkKafkaProducer<String, String> getClosedProducer(String topicName) {
	FlinkKafkaProducer<String, String> kafkaProducer = new FlinkKafkaProducer<>(extraProperties);
	kafkaProducer.initTransactions();
	kafkaProducer.beginTransaction();
	kafkaProducer.send(new ProducerRecord<>(topicName, "42", "42"));
	kafkaProducer.close();
	return kafkaProducer;
}
 
Example 3
Source File: FlinkKafkaProducerITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 30000L, expected = IllegalStateException.class)
public void testBeginTransactionAfterClosed() {
	FlinkKafkaProducer<String, String> kafkaProducer = new FlinkKafkaProducer<>(extraProperties);
	kafkaProducer.initTransactions();
	kafkaProducer.close();
	kafkaProducer.beginTransaction();
}
 
Example 4
Source File: FlinkKafkaProducerITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
private FlinkKafkaProducer<String, String> getClosedProducer(String topicName) {
	FlinkKafkaProducer<String, String> kafkaProducer = new FlinkKafkaProducer<>(extraProperties);
	kafkaProducer.initTransactions();
	kafkaProducer.beginTransaction();
	kafkaProducer.send(new ProducerRecord<>(topicName, "42", "42"));
	kafkaProducer.close();
	return kafkaProducer;
}
 
Example 5
Source File: FlinkKafkaProducer011.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private void recycleTransactionalProducer(FlinkKafkaProducer<byte[], byte[]> producer) {
	availableTransactionalIds.add(producer.getTransactionalId());
	producer.close();
}
 
Example 6
Source File: FlinkKafkaProducer011.java    From flink with Apache License 2.0 4 votes vote down vote up
private void recycleTransactionalProducer(FlinkKafkaProducer<byte[], byte[]> producer) {
	availableTransactionalIds.add(producer.getTransactionalId());
	producer.close();
}
 
Example 7
Source File: FlinkKafkaProducerITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 30000L, expected = IllegalStateException.class)
public void testPartitionsForAfterClosed() {
	FlinkKafkaProducer<String, String> kafkaProducer = new FlinkKafkaProducer<>(extraProperties);
	kafkaProducer.close();
	kafkaProducer.partitionsFor("Topic");
}
 
Example 8
Source File: FlinkKafkaProducerITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 30000L, expected = IllegalStateException.class)
public void testInitTransactionsAfterClosed() {
	FlinkKafkaProducer<String, String> kafkaProducer = new FlinkKafkaProducer<>(extraProperties);
	kafkaProducer.close();
	kafkaProducer.initTransactions();
}
 
Example 9
Source File: FlinkKafkaProducer011.java    From flink with Apache License 2.0 4 votes vote down vote up
private void recycleTransactionalProducer(FlinkKafkaProducer<byte[], byte[]> producer) {
	availableTransactionalIds.add(producer.getTransactionalId());
	producer.flush();
	producer.close(0, TimeUnit.SECONDS);
}
 
Example 10
Source File: FlinkKafkaProducerITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 30000L, expected = IllegalStateException.class)
public void testPartitionsForAfterClosed() {
	FlinkKafkaProducer<String, String> kafkaProducer = new FlinkKafkaProducer<>(extraProperties);
	kafkaProducer.close();
	kafkaProducer.partitionsFor("Topic");
}
 
Example 11
Source File: FlinkKafkaProducerITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 30000L, expected = IllegalStateException.class)
public void testInitTransactionsAfterClosed() {
	FlinkKafkaProducer<String, String> kafkaProducer = new FlinkKafkaProducer<>(extraProperties);
	kafkaProducer.close();
	kafkaProducer.initTransactions();
}