Changing the default timeout of Spring Kafka replying template

Viewed 26

We are using AggregatingReplyingKafkaTemplate for sending and recieving a reply of messages.

I want to increase the timeout. But it seems the Kafka Listener is timing out in this case in around 30-40 seconds.

I have tried increasing the default timeout to 10 mins (just for testing ). But it did not help

aggregatingReplyingKafkaTemplate.setDefaultReplyTimeout(Duration.ofSeconds(600)); //changing the default timeout

Code when we are sending the message

private final AggregatingReplyingKafkaTemplate<String, T, R> aggregatingReplyingKafkaTemplate;

public RequestReplyFuture<String, T, Collection<ConsumerRecord<String, R>>> sendAndReceive(String producerTopic, T record, Headers headers) {
    ProducerRecord<String, T> producerRecord = new ProducerRecord(producerTopic, record);
    addHeaders(producerRecord, headers);
    return this.aggregatingReplyingKafkaTemplate.sendAndReceive(producerRecord);
}

Best Regards,

Saurav

1 Answers

I was using DeferredResult for async request with a timeout which was causing my original HTTP request to time out. This HTTP request was internally using ReplyingTemplate to communicate with the downstream services.

I did increase the ReplyingTemplate's default timeout as i mentioned above.

So, its working now.

Related