0

I have a SCDF processor which produces multiple outputs per input. The list of outputs could be rather large. That's why I was thinking of streaming the results from JPA repository.

@Service
public class ProcessorFunction implements Function<Parent, Stream<Message<Child>>> {

    @Autowired
    private ChildRepository repo;

    @Override
    @Transactional(readOnly = true)
    public Stream<Message<Child>> apply(Parent parent) {
        try (var stream = repo.findByParentId(parent.getId())) {
            return stream.map(GenericMessage::new);
        }
    }
}
public interface ChildRepository extends  JpaRepository<Child, Long> {
  
  Stream<Child> FindByParentId(long id);
}

I expected that the stream will send the list of output on the output channel. However, only null values are being sent.

I have gone through spring-cloud-dataflow document as well as spring-cloud-stream documentation but could not find my use case.

Kindly help!

Juzer Ali
  • 4,109
  • 3
  • 35
  • 62

0 Answers0