Spring Cloud Stream Batch Consumer and Batch Publisher using Function
Consumer
spring.cloud.stream.bindings.receiveMessage-in-0.consumer.batch-mode=true
spring.cloud.stream.solace.bindings.receiveMessage-in-0.consumer.batchMaxSize=255
spring.cloud.stream.solace.bindings.receiveMessage-in-0.consumer.batchTimeout=500
### Publish messages to Topic
spring.cloud.stream.bindings.receiveMessage-out-0.destination = <<Topic Name>>
1st Mircoservice:
Function<Message<List<String>>, List<//USER Defined Object -1//>> receiveMessage()
2nd Microservice:
public Function<List<//USER Defined Object -1//>, List<//USER Defined Object - 2//>> messageReceiver()
This mircroservice listening to the topic is also function with batch-mode = true
The issue faced is , the 2nd Microservice is getting the payload/input as bytes instead of the pojo when in batch-mode = true.
Any inputs/suggestions please?
Answers
-
Hi @kirthi - If you want to receive messages as a batch in the 2nd microservice, you need to construct the messages as a batch (collection) and return them in the 1st microservice.
So the function signature of 1st microservice would be
Function<Message<List<String>>, List<Message<POJO>>> receiveMessage()
And the function signature of 2nd microservice would be
Function<Message<List<POJO>>, List<POJO> messageReceiver()
This seems to do the job - if you have found anything, please share.
0