Search code examples
spring-cloud-dataflow

SCDF processor reads one message and outputs arrays of objects, but sink can handle single item


My Processor process one payload and produce a List

  @StreamListener(Processor.INPUT)
  @SendTo(Processor.OUTPUT)
  public List<XYZObject> getAll(
      XYZInput inp) {
      List<XYZObject> xyzs = dbService.findAllByDataType(inp.getDataType());
      return xyzs;
  }

The stream has RabbitMQ middleware, and my sink looks like below:

@StreamListener(Sink.INPUT)
  public void writeToX(XYZInput input) {
    ....
  }

I took a look into a similar discussion Similar Problem with Kafka Binder. How to achieve this with Rabbit binder?

Is it achieveable with RabbitMQ as binder?


Solution

  • This is a Spring Cloud Stream question and is controlled by the spring.cloud.stream.bindings.<binding-name>.consumer.batch-mode property.

    Please see the reference guide section for Batch consumers/producers to learn more.