NewsProducer { public RecordMetadata send(News news) throws ExecutionException, InterruptedException { ProducerRecord<String, News> record = new ProducerRecord<>(topic, news.id.toString(), news); return this.producer.send(record).get(); } NewsProducer(String producerName, String topic, String broker); RecordMetadata send(News news); Future<RecordMetadata> sendAsync(News news); void close();  }
@Test public void sendSportNews() throws Exception { News news = new News(UUID.randomUUID(), "Marcel Tau", "Bayern München - Deutscher Meister", LOREM_IPSUM.paragraph()); sportProducer.send(news); }
@Test public void sendBusinessNews() throws Exception { logger.info("Sending 1000 messages"); long start = System.currentTimeMillis(); for (int i = 0; i < 1000; i++) { News news = new News(UUID.randomUUID(), "Dr. Rainer Zufall", LOREM_IPSUM.paragraph(), LOREM_IPSUM.paragraph()); businessProducer.send(news); } logger.info("Sent 1000 msgs in {}ms", System.currentTimeMillis() - start); }