I am writing Junit test cases(using @EmbeddedKafka) for my Spring Boot application which extensively uses Spring-kafka to communicate with other services and for other operations.
One typical case is deleting the data from kafka (which we are doing with pushing null message in kafka).
Currently in delete() method we are doing this by first checking if there exist any message in kafka that is requested to be deleted. Then we push null for that message key in Kafka
Steps followed in writing Junit for above method logic.
@Test
public void test(){
//Push a message to Kafka (id=1234)
//call test method service.delete(1234);
//internally service.delete(1234) checks/validate whether message exists in kafka and then push null to delete topic.
//check delete topic for delete message received.
// Assertions
}
Problem here is Kafka always throws message not found exception. inside service.delete() method.
while checking logs in console. i figured out that my producer-config using a different port for kafka while consumer config using a diferent port.
I am not sure whether i have missed some minute detail or what is the reason for this behaviour. Any help will be appreciated.