fmdaboville
fmdaboville

Reputation: 1831

Spring integration : handle a File given in arguments

I have an existing Spring Integration app, which handle files coming from FTP with InboundChannelAdapter. I want to plug Spring boot to this app to use it now like this :

java -jar app.jar <filetohandlepath>

So, the application start with this command, and stop at the end of the treatment. But my question is how can I run my existing channels (ServiceActivator) to give this file to handle ?

What about Spring Boot, to handle the argument ? I need to build the message into the main method, or in an other class with a scan ?

I just need to know the best way to design my app.

Upvotes: 1

Views: 157

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121560

Your FTP Inbound Channel Adapter polls remote file to local files and sends them as payload of messages into some channel for the mentioned Service Activator. Of course you can send message manually to the same channel with the payload accepted by that Service Activator subscriber. Yes, you can use @MessagingGateway to separate Messaging concern from your code. Or you can just rely on the MessagingTemplate and its convertAndSend() API. Any convenient way for you is acceptable: https://docs.spring.io/spring-integration/docs/5.0.4.RELEASE/reference/html/messaging-endpoints-chapter.html#gateway

As for Spring Boot and command line arguments, you definitely can take a look into the CommandLineRunner: https://docs.spring.io/spring-boot/docs/2.0.1.RELEASE/reference/htmlsingle/#boot-features-command-line-runner

Upvotes: 1

Related Questions