0

Im working with Spring Integration and am working with files. I'm using the provided DSL to process my files. At the end of my integration flow I am outputting the result to a new file using Files.outboundGateway(...) . However I keep getting the following error no output-channel or replyChannel header available. According to the post at the bottom of this post the solution is to set the expected reply to false but, how do I do that with the DSL?

Below shows what I'm doing in the last part of my integration flow to write to a file.

.handle(Files.outboundGateway(new File(outputFilePath))
                    .autoCreateDirectory(true)
                    .fileExistsMode(FileExistsMode.APPEND)
                    .appendNewLine(true)
                    .fileNameGenerator(m -> m.getHeaders().getOrDefault("file_name", "outputFile") + "_out.txt")
                    
                    )
            .get();

Spring Integration error "no output-channel or replyChannel header available"

Elwin
  • 19
  • 4

1 Answers1

1

Consider using an outboundAdapter() instead of gateway since you are not going to deal with the writing result and this is the end of your flow:

/**
 * Create a {@link FileWritingMessageHandlerSpec} builder for the one-way {@code FileWritingMessageHandler}.
 * @param destinationDirectory the target directory to write files.
 * @return the {@link FileWritingMessageHandlerSpec} instance.
 */
public static FileWritingMessageHandlerSpec outboundAdapter(File destinationDirectory) {
Artem Bilan
  • 113,505
  • 11
  • 91
  • 118