Kafka template not able to send topics when running through integration tests

Hi Rajesh,

I’m not familiar with Spring Kafka, but I don’t see where a broker gets started from looking at this code. Is there another configuration/annotation to set to specify running in a transaction? Does this work without transactions?

Hi Bill,

Thanks for your reply… It’s Embeededkafka Below is the code for that Kafka Broker configuration and even without transaction not able to send topic…

@EmbeddedKafka(
count = 1,
brokerProperties = {
“listeners=PLAINTEXT://localhost:9092”,
“port=9092”
}
)
public class EventsTest {

@Test
public void sendTopic1(){
Properties config = new Properties();
config.put(ProducerConfig.CLIENT_ID_CONFIG, InetAddress.getLocalHost().getHostName());
config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, broker.getBrokersAsString());
config.put(ProducerConfig.ACKS_CONFIG, “all”);
config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);
config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);
KafkaProducer<String, Event> producer = new KafkaProducer<String, Event>(
config);
ProducerRecord<String, Event> record = new ProducerRecord<>(“topic1”, keyString, Event);
Future future = producer.send(record);
}

}

Hi Rajesh,

I’ve taken a look at your example here and nothing jumps out at me, but again I’m not familiar with SpringKafka I did a quick search, and I something promising.

HTH,
Bill