spring-kafka icon indicating copy to clipboard operation
spring-kafka copied to clipboard

Optimize a `MessagingMessageListenerAdapter` returning `null` from the `DelegatingInvocableHandler.invoke()`

Open artembilan opened this issue 10 months ago • 4 comments
trafficstars

Right now the DelegatingInvocableHandler.invoke() always returns an InvocationResult even if result == null. In the end we may just have a log message like:

Async result is null, ignoring

which is not always true for the regular void @KafkaHandler method.

Changing the logic in the mention method to:

		if (result != null) {
			return new InvocationResult(result, this.handlerSendTo.get(handler),
					this.handlerReturnsMessage.get(handler));
		}
		else {
			return null;
		}

would make some optimization where we would not try to resolve any reply attempts and creation of many interim objects like CompletableFuture.

Since this would be a breaking change, the issue is scheduled for the next 4.0 major version.

artembilan avatar Dec 31 '24 17:12 artembilan

Hi, @artembilan!

Could I work on this issue?

Thanks!

ivamly avatar Jan 16 '25 18:01 ivamly

@ivamly Yes, please go ahead.

sobychacko avatar Jan 16 '25 19:01 sobychacko

See the comment on the latest PR. https://github.com/spring-projects/spring-kafka/pull/3710#issuecomment-2597068984

sobychacko avatar Jan 16 '25 22:01 sobychacko

I'll make another PR soon, no problem.

ivamly avatar Jan 17 '25 04:01 ivamly