SylvainM
SylvainM

Reputation: 21

Spring data stream, FTP source custom headers

Scenario :

Code :

@SpringBootApplication
@Import({ FtpSourceConfiguration.class, AWSLocalStackConfig.class })
public class FtpSourceKinesisApplication {

  public static void main(String[] args) {
    SpringApplication.run(FtpSourceKinesisApplication.class, args);
  }
}


Todo :

Is there a way to do it without creating the IntegrationFlow myself ?

Upvotes: 1

Views: 128

Answers (2)

SylvainM
SylvainM

Reputation: 21

Based on Oleg's comment, this is what I did :

@Component
public class SourceHeaderEnricher implements ChannelInterceptor {

  SourceHeaderEnricher (Source source) {
    ((ChannelInterceptorAware) source.output()).addInterceptor(this);
  }

  @Override
  public Message<?> preSend(Message<?> message, MessageChannel channel) {
    MessageBuilder<?> builder = MessageBuilder.fromMessage(message);
    builder.setHeader("x-custom", "hello world");
    return builder.build();
  }
}

This is working if you are implementing your own app. To do it using the bare starter apps, apparently we need to wait for the next version.

Upvotes: 0

Oleg Zhurakousky
Oleg Zhurakousky

Reputation: 6106

@SylvainM Ironically we are currently working on providing such support to all our app starters. I mean you can do it now by simply adding channel interceptor to the output channel of your Sopurce, but what's coming down the pipeline is going to be much simpler and based on Spring Cloud Functions. Watch for the blog on that.

Upvotes: 1

Related Questions