use of org.apache.kafka.common.serialization.BytesSerializer in project flink by apache.
the class KafkaContainerClient method sendMessages.
public <T> void sendMessages(String topic, Serializer<T> valueSerializer, T... messages) {
Properties props = new Properties();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, container.getBootstrapServers());
props.put(ProducerConfig.ACKS_CONFIG, "all");
try (Producer<Bytes, T> producer = new KafkaProducer<>(props, new BytesSerializer(), valueSerializer)) {
for (T message : messages) {
producer.send(new ProducerRecord<>(topic, message));
}
}
}
Aggregations