I have a project using spring-boot-cloud and apache-kafka, I have a list of integration test covering the topology logic, thanks to EmbeddedBroker.
I recently discovered that there are many noise in the log when running these tests.
e.g. [Producer clientId=producer-2] Connection to node 0 (localhost/127.0.0.1:63267) could not be established. Broker may not be available.
After some trial and error it appears that these were the producers created by the spring-cloud-stream bindings. Somehow with @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) on the class level they do not appear to be cleaned up after each test.
Thus I figured if I can get access to the producer factory I can then manually clean them up inside the @AfterEach clause of my test class. I've tried to autowire KafkaTemplate but it didn't help. I don't know how I can access the producer factory since it's created implicitly by the framework.
Please be noted that these do not appear to affect the test result since they only show up at the end of the test phase.
Thanks in advance!