I am using Reactor to read from a Kafka topic. The elaboration of each message requests a query into a MongoDB, that is slower than the read of messages from the Kafka topic. So, I applied backpressure handling to the stream.
receiver.receive()
// Limiting the reading operation
.limitRate(50)
// processMessage accesses to the database
.flatMap(this::processMessage)
.publish()
// Simplification here
.subscribe();
I am using a ConnectableFlux
to have more than one subscriber to the KafkaReceiver
producer. KafkaReceiver
does not allow more than one subscriber natively.
I need to test if my code applies backpressure correctly to the stream. How can I do that, using some integration tests?
Thanks to all.