use of org.apache.flink.streaming.connectors.kafka.partitioner.FlinkFixedPartitioner in project flink by apache.
the class KafkaChangelogTableITCase method writeRecordsToKafka.
private void writeRecordsToKafka(String topic, List<String> lines) throws Exception {
DataStreamSource<String> stream = env.fromCollection(lines);
SerializationSchema<String> serSchema = new SimpleStringSchema();
FlinkKafkaPartitioner<String> partitioner = new FlinkFixedPartitioner<>();
// the producer must not produce duplicates
Properties producerProperties = getStandardProps();
producerProperties.setProperty("retries", "0");
stream.sinkTo(KafkaSink.<String>builder().setBootstrapServers(producerProperties.getProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)).setRecordSerializer(KafkaRecordSerializationSchema.builder().setTopic(topic).setValueSerializationSchema(serSchema).setPartitioner(partitioner).build()).setDeliverGuarantee(DeliveryGuarantee.EXACTLY_ONCE).build());
env.execute("Write sequence");
}
Aggregations