1

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.

riccardo.cardin
  • 7,971
  • 5
  • 57
  • 106

1 Answers1

0

The Reactive Streams project has a test suite (called TCK) to test implementations of reactive streams (including backpressure). I used it to test my implementation of the Publisher interface: https://github.com/akaigoro/df4j/tree/API-7/df4j-reactive-tck.

Alexei Kaigorodov
  • 13,189
  • 1
  • 21
  • 38