mardi 24 septembre 2019

Citrus framework: not fail test on receive timeout

In my citrus test, I want to verify the number of specific messages in the Kafka topic. However, receive function fails the test if there are no messages in the topic in the configured timeout window.

This is what I've tried:

receive(receiveMessageBuilder -> receiveMessageBuilder
                    .endpoint(topic)
                    .messageType(MessageType.PLAINTEXT)
                    .validator(new KafkaCounterMessageValidator(counter, 1, context.getVariable(FILENAME))))
            );

I wanted to call this function in a loop for some time and write in the test context's variable number of messages to verify it later. However, the problem is that If I want to have exactly N messages in the topic I need to call this function at least N+1 times, which, in most cases, will fail the test because there will be no messages and ActionTimeoutException will rise.

Is there a way to turn off this kind of behaviour or implement it the other way?

Aucun commentaire:

Enregistrer un commentaire