Questions tagged [spring-kafka-test]
134 questions
4
votes
1 answer
Spring Kafka test with embedded Kafka failed on deleting logs
I am using spring kafka with the embedded kafka for JUnit test, it gives an error for every test on windows:
Error deleting C:\Users:LXX691\AppData\Local\Temp\kafka-1103610162480947200/.lock: The process cannot access the file because it is being…

Jakim
- 1,713
- 7
- 20
- 44
4
votes
2 answers
How to test a kafka consumer against a real kafka broker running on a server?
I have difficulty understanding some Kafka concepts in Java Spring Boot. I’d like to test a consumer against a real Kafka broker running on a server, which has some producers that write / have already written data to various topics. I would like to…

SkogensKonung
- 601
- 1
- 9
- 22
4
votes
1 answer
Embedded Kafka Refresh Messages Between Tests
I'm using Spring Kafka with the the @EmbeddedKafka annotation to start the Embedded kafka instance.
Dependency:
org.springframework.kafka
spring-kafka-test
…

George
- 2,820
- 4
- 29
- 56
4
votes
1 answer
Sending using KafkaTemplate returns a exception for using String as a key
When using Integer as a key this is not a problem, kafka should be able to handle Strings as a key.
ProducerFactory pf =
new DefaultKafkaProducerFactory(senderProps);
KafkaTemplate…

kambo
- 129
- 2
- 11
3
votes
1 answer
Embedded Kafka Test - The Kafka listener is not invoked
I have created a unit test to test the Kafka listener as shown below.
@SpringBootTest
@EmbeddedKafka(partitions = 1, brokerProperties = {"listeners=PLAINTEXT://localhost:9092","port=909"})
class ConsumerTest {
@Autowired
KafkaTemplate…

SmartTechie
- 135
- 2
- 10
3
votes
1 answer
Error creating bean with name 'embeddedKafka': Invocation of init method failed
I created a simple test case to initiate my Spring Kafka Test. I am using Spring-Kafka version 2.5.6.RELEASE and Junit5. I followed the doc here.
@DirtiesContext
@ActiveProfiles("test")
@SpringBootTest()
@EmbeddedKafka
public class KafkaTests {
…

Steephen
- 14,645
- 7
- 40
- 47
3
votes
1 answer
Spring Boot and Kafka upgrade broke my tests
I have updated the libraries of one project, in particular, I've updated Spring Boot, from version 2.2.6 to 2.3.2.
As mentioned in the migration documentation, this would also mean a change in my Kafka dependencies, going up to Spring Kafka and…

Mangu
- 3,160
- 2
- 25
- 42
3
votes
1 answer
spring kafka properties not auto loaded when writing customConsumerFactory and customKafkaListenerContainerFactory
I want to load my spring-kafka properties from application.properties and that must be loaded using spring auto configuration. My problem is Caused by: java.lang.IllegalStateException: No Acknowledgment available as an argument, the listener…

SDB
- 95
- 1
- 8
3
votes
2 answers
EmbeddedKafka not working cause an Scala error
I have a working spring-boot java-gradle-based service that can produce and consume Kafka messages. But I can't create an integration test using spring-kafka-test library with @EmbeddedKafka annotation or using @ClassRule way. In both ways, I end up…

agcr
- 53
- 1
- 5
3
votes
0 answers
SASL_SSL integration with EmbeddedKafka
I've been following this blog post to implement an embedded sasl_ssl
https://sharebigdata.wordpress.com/2018/01/21/implementing-sasl-plain/
@SpringBootTest
@RunWith(SpringRunner.class)
@TestPropertySource(properties = {
…

bryce
- 479
- 1
- 6
- 13
2
votes
1 answer
Tests fail to start using spring-kafka-test (NoClassDefFoundError)
I am testing a feature that uses a Kafka producer and listener, with the help of spring-kafka-test.
Both spring-kafka and spring-kafka-test are using the 2.8.2 version.
My test classes use the @EmbeddedKafka annotation as…

ojathelonius
- 685
- 8
- 26
2
votes
1 answer
Spring boot embedded kafka throws error BeanCreationException
I have a test case with following configured kafka properties:
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = {Application.class})
@ActiveProfiles("test")
@EnableConfigurationProperties
@EmbeddedKafka(controlledShutdown = true, topics…

DeeP
- 23
- 1
- 5
2
votes
1 answer
Kafka transactional producer throws 'Timeout expired while initializing transactional state in 60000ms'
I have configured a Kafka ProducerFactory with a transactionIdPrefix, in order to enable transaction synchronization using @Transactional (see Spring documentation on producer-only transactions).
I'm running an EmbeddedKafka in my integration test,…
user16648989
2
votes
0 answers
spring kafka, how to gracefully shutdown the spring boot application
I am having Kafka Consumers in a Spring Boot application. I have kept ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG as false and my consumers are manually acknowledging the messages.
Spring-Kafka: 2.2.11.RELEASE
My configuration:
@Override
public…

JDev
- 1,662
- 4
- 25
- 55
2
votes
0 answers
Mock unit testing with Kafka - callback mockproducer
I would like to setup some tests around calling Kafka. I have the following callback setup with my Kafka call, see below:
@Async // allows function to be async. the config also has to be set
@Override
public void publishEventToTopic() {
…

rj2700
- 1,770
- 6
- 28
- 55