Closed ellogi closed 1 month ago
This was resolved via a series of commits ins spring-cloud-stream
5d881b2ad 29a355832 058fc660a fac9eb1eb 14c10462f
As well as the commit in spring-cloud-function
6dee668e3
It was alos back-ported to 4.1.x and will be available with the next release
@olegz Do you know when 4.1.4 will be built?
I use Spring cloud stream kafka binder with functions to describe my kafka consumer and consume messages in batch mode.
And properties is
If one of the input kafka json messages couldn't be deserialized in
org.springframework.cloud.function.context.config.JsonMessageConverter#convertFromInternal
for any reason, then exception is swallowed silently and null is returned. After thatSmartCompositeMessageConverter#fromMessage(org.springframework.messaging.Message<?>, java.lang.Class<?>, java.lang.Object)
just doesn't add that message to converted result. So If one item in message.payload got this conversion error, but the second one does not, thenconvertedInput
inSimpleFunctionRegistry.FunctionInvocationWrapper#convertInputMessageIfNecessary
would have only second item without any exception or error message, but at the same time it would still have two item of headers becauseconvertedInput
is checked only on null and doesn't be checked that it has the same count of input and converted messages. So, finally in my consumer function I getmessages
with 1 message in payload and 2 item in headers and, moreover, the order in headers is incorrect. I mean that the first header is for the lost message, not for the presented, but it is impossible to determine it.Here in the end
convertedInput = MessageBuilder.withPayload(convertedInput).copyHeaders(message.getHeaders()).build();
we have one item inconvertedInput
, but copy all original headersIs it a correct behavior and I must always check count of headers and count of items in payload in consumer? Or maybe I miss some properties or error handling or anything else? And I am also unsure that losing incorrect input messages silently is correct. Thanks in advance for any feedback.
Affects at least version 3.2.12