Class KafkaClient
- java.lang.Object
-
- dev.lydtech.component.framework.client.kafka.KafkaClient
-
public final class KafkaClient extends Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<org.apache.kafka.clients.consumer.ConsumerRecord<String,String>>consumeAndAssert(String testName, org.apache.kafka.clients.consumer.Consumer consumer, int expectedEventCount, int furtherPolls)1.org.apache.kafka.clients.consumer.ConsumercreateConsumer(String groupId, String topic)org.apache.kafka.clients.producer.Producer<Long,String>createProducer()static KafkaClientgetInstance()voidsendMessage(String topic, String key, String payload)
-
-
-
Method Detail
-
getInstance
public static KafkaClient getInstance()
-
createConsumer
public org.apache.kafka.clients.consumer.Consumer createConsumer(String groupId, String topic)
-
sendMessage
public void sendMessage(String topic, String key, String payload) throws Exception
- Throws:
Exception
-
consumeAndAssert
public List<org.apache.kafka.clients.consumer.ConsumerRecord<String,String>> consumeAndAssert(String testName, org.apache.kafka.clients.consumer.Consumer consumer, int expectedEventCount, int furtherPolls) throws Exception
1. Poll for messages on the application’s outbound topic. 2. Assert the expected number are received. 3. Performs the specified number of extra polls after the expected number received to ensure no further events. 4. Returns the consumed events.- Throws:
Exception
-
-