Java Outbound Adaptor processing











up vote
1
down vote

favorite












I have created an application that adds inbound adaptors at run time for ftp servers and registers them for removing at a certain stage if needed, this app will pull a csv file from ftp server(s) and place it in my local in a folder having the name of the ftp server, so every server I add will have a separate local folder created and the csv file is saved in it, now this is accomplished smoothly, the second part is I want to change the format of that file and then send it back to the respective server, so basically I need to use outbound adaptor, in this case I would need to create outbound adaptors at run time at the same time when creating inbound adaptor or adding a server, this should be done through controller same as the inbound, I searched for possible solutions and tried a one that is below but did not work or did not perform any sending of files to destination, any solution on how I can accomplish this?
In the configuration class I added the below:



public IntegrationFlow ftpOutboundFlow(Branch myBranch){

return IntegrationFlows.from(OUTBOUND_CHANNEL)
.handle(Ftp.outboundAdapter(createNewFtpSessionFactory(myBranch), FileExistsMode.FAIL)
.useTemporaryFileName(true)
.remoteFileSeparator("/")
//.fileNameExpression("BEY/FEFOexportBEY.csv")
.remoteDirectory(myBranch.getFolderPath()))
.get();

}

@MessagingGateway
public interface MyGateway {

@Gateway(requestChannel = OUTBOUND_CHANNEL)
void sendToFtp(File file);

}



@Bean
public IntegrationFlow ftpOutboundChannel() {

return IntegrationFlows.from(OUTBOUND_CHANNEL)
.publishSubscribeChannel(p -> p
.subscribe(t -> t.handle(System.out::println)))
/*.transform(p -> {
LOG.info("Outbound intermediate Channel, message=rename file:" + p);
return p;
})*/
.channel(new NullChannel())
.get();
}


And in the Controller class



@RequestMapping("/branch/showbranch/{id}")
public String getBranch (@PathVariable String id, Model model){
model.addAttribute("branch", branchService.getById(Long.valueOf(id)));
addFlowftp(id);
addFlowftpOutbound(id);
return "/branch/showbranch";

}

private void addFlowFtp(String name) {
branch = branchService.getById(Long.valueOf(name));
System.out.println(branch.getBranchCode());
IntegrationFlow flow = ftIntegration.fileInboundFlowFromFTPServer(branch);
this.flowContext.registration(flow).id(name).register();
}

private void addFlowftpOutbound(String name) {
branch = branchService.getById(Long.valueOf(name));
System.out.println(branch.getBranchCode());
IntegrationFlow flow = ftIntegration.ftpOutboundFlow(branch);
// this.flowContext.registration(flow).id(name).register();
myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));
}


Here is what I get in the consol as error when I enable the register before sending the file:



java.lang.IllegalArgumentException: An IntegrationFlow 'IntegrationFlowRegistration{integrationFlow=StandardIntegrationFlow{integrationComponents={org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer@aadab28=98.org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer#0, org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean@aa290b3=stockInboundPoller, org.springframework.integration.transformer.MethodInvokingTransformer@e5f85cd=98.org.springframework.integration.transformer.MethodInvokingTransformer#0, 98.channel#0=98.channel#0, org.springframework.integration.config.ConsumerEndpointFactoryBean@319dff2=98.org.springframework.integration.config.ConsumerEndpointFactoryBean#0}}, id='98', inputChannel=null}' with flowId '98' is already registered.
An existing IntegrationFlowRegistration must be destroyed before overriding.


After my second trial where I removed the registration from the first method and only tried with the second method but nothing was sent to the FTP:



GenericMessage [payload=BEYFEFOexportBEY.csv, headers={id=43cfc2db-41e9-0866-8e4c-8e95968189ff, timestamp=1542702869007}]
2018-11-20 10:34:29.011 INFO 13716 --- [nio-8081-exec-6] f.s.s.configuration.FTIntegration : Outbound intermediate Channel, message=rename file:BEYFEFOexportBEY.csv









share|improve this question




























    up vote
    1
    down vote

    favorite












    I have created an application that adds inbound adaptors at run time for ftp servers and registers them for removing at a certain stage if needed, this app will pull a csv file from ftp server(s) and place it in my local in a folder having the name of the ftp server, so every server I add will have a separate local folder created and the csv file is saved in it, now this is accomplished smoothly, the second part is I want to change the format of that file and then send it back to the respective server, so basically I need to use outbound adaptor, in this case I would need to create outbound adaptors at run time at the same time when creating inbound adaptor or adding a server, this should be done through controller same as the inbound, I searched for possible solutions and tried a one that is below but did not work or did not perform any sending of files to destination, any solution on how I can accomplish this?
    In the configuration class I added the below:



    public IntegrationFlow ftpOutboundFlow(Branch myBranch){

    return IntegrationFlows.from(OUTBOUND_CHANNEL)
    .handle(Ftp.outboundAdapter(createNewFtpSessionFactory(myBranch), FileExistsMode.FAIL)
    .useTemporaryFileName(true)
    .remoteFileSeparator("/")
    //.fileNameExpression("BEY/FEFOexportBEY.csv")
    .remoteDirectory(myBranch.getFolderPath()))
    .get();

    }

    @MessagingGateway
    public interface MyGateway {

    @Gateway(requestChannel = OUTBOUND_CHANNEL)
    void sendToFtp(File file);

    }



    @Bean
    public IntegrationFlow ftpOutboundChannel() {

    return IntegrationFlows.from(OUTBOUND_CHANNEL)
    .publishSubscribeChannel(p -> p
    .subscribe(t -> t.handle(System.out::println)))
    /*.transform(p -> {
    LOG.info("Outbound intermediate Channel, message=rename file:" + p);
    return p;
    })*/
    .channel(new NullChannel())
    .get();
    }


    And in the Controller class



    @RequestMapping("/branch/showbranch/{id}")
    public String getBranch (@PathVariable String id, Model model){
    model.addAttribute("branch", branchService.getById(Long.valueOf(id)));
    addFlowftp(id);
    addFlowftpOutbound(id);
    return "/branch/showbranch";

    }

    private void addFlowFtp(String name) {
    branch = branchService.getById(Long.valueOf(name));
    System.out.println(branch.getBranchCode());
    IntegrationFlow flow = ftIntegration.fileInboundFlowFromFTPServer(branch);
    this.flowContext.registration(flow).id(name).register();
    }

    private void addFlowftpOutbound(String name) {
    branch = branchService.getById(Long.valueOf(name));
    System.out.println(branch.getBranchCode());
    IntegrationFlow flow = ftIntegration.ftpOutboundFlow(branch);
    // this.flowContext.registration(flow).id(name).register();
    myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));
    }


    Here is what I get in the consol as error when I enable the register before sending the file:



    java.lang.IllegalArgumentException: An IntegrationFlow 'IntegrationFlowRegistration{integrationFlow=StandardIntegrationFlow{integrationComponents={org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer@aadab28=98.org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer#0, org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean@aa290b3=stockInboundPoller, org.springframework.integration.transformer.MethodInvokingTransformer@e5f85cd=98.org.springframework.integration.transformer.MethodInvokingTransformer#0, 98.channel#0=98.channel#0, org.springframework.integration.config.ConsumerEndpointFactoryBean@319dff2=98.org.springframework.integration.config.ConsumerEndpointFactoryBean#0}}, id='98', inputChannel=null}' with flowId '98' is already registered.
    An existing IntegrationFlowRegistration must be destroyed before overriding.


    After my second trial where I removed the registration from the first method and only tried with the second method but nothing was sent to the FTP:



    GenericMessage [payload=BEYFEFOexportBEY.csv, headers={id=43cfc2db-41e9-0866-8e4c-8e95968189ff, timestamp=1542702869007}]
    2018-11-20 10:34:29.011 INFO 13716 --- [nio-8081-exec-6] f.s.s.configuration.FTIntegration : Outbound intermediate Channel, message=rename file:BEYFEFOexportBEY.csv









    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have created an application that adds inbound adaptors at run time for ftp servers and registers them for removing at a certain stage if needed, this app will pull a csv file from ftp server(s) and place it in my local in a folder having the name of the ftp server, so every server I add will have a separate local folder created and the csv file is saved in it, now this is accomplished smoothly, the second part is I want to change the format of that file and then send it back to the respective server, so basically I need to use outbound adaptor, in this case I would need to create outbound adaptors at run time at the same time when creating inbound adaptor or adding a server, this should be done through controller same as the inbound, I searched for possible solutions and tried a one that is below but did not work or did not perform any sending of files to destination, any solution on how I can accomplish this?
      In the configuration class I added the below:



      public IntegrationFlow ftpOutboundFlow(Branch myBranch){

      return IntegrationFlows.from(OUTBOUND_CHANNEL)
      .handle(Ftp.outboundAdapter(createNewFtpSessionFactory(myBranch), FileExistsMode.FAIL)
      .useTemporaryFileName(true)
      .remoteFileSeparator("/")
      //.fileNameExpression("BEY/FEFOexportBEY.csv")
      .remoteDirectory(myBranch.getFolderPath()))
      .get();

      }

      @MessagingGateway
      public interface MyGateway {

      @Gateway(requestChannel = OUTBOUND_CHANNEL)
      void sendToFtp(File file);

      }



      @Bean
      public IntegrationFlow ftpOutboundChannel() {

      return IntegrationFlows.from(OUTBOUND_CHANNEL)
      .publishSubscribeChannel(p -> p
      .subscribe(t -> t.handle(System.out::println)))
      /*.transform(p -> {
      LOG.info("Outbound intermediate Channel, message=rename file:" + p);
      return p;
      })*/
      .channel(new NullChannel())
      .get();
      }


      And in the Controller class



      @RequestMapping("/branch/showbranch/{id}")
      public String getBranch (@PathVariable String id, Model model){
      model.addAttribute("branch", branchService.getById(Long.valueOf(id)));
      addFlowftp(id);
      addFlowftpOutbound(id);
      return "/branch/showbranch";

      }

      private void addFlowFtp(String name) {
      branch = branchService.getById(Long.valueOf(name));
      System.out.println(branch.getBranchCode());
      IntegrationFlow flow = ftIntegration.fileInboundFlowFromFTPServer(branch);
      this.flowContext.registration(flow).id(name).register();
      }

      private void addFlowftpOutbound(String name) {
      branch = branchService.getById(Long.valueOf(name));
      System.out.println(branch.getBranchCode());
      IntegrationFlow flow = ftIntegration.ftpOutboundFlow(branch);
      // this.flowContext.registration(flow).id(name).register();
      myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));
      }


      Here is what I get in the consol as error when I enable the register before sending the file:



      java.lang.IllegalArgumentException: An IntegrationFlow 'IntegrationFlowRegistration{integrationFlow=StandardIntegrationFlow{integrationComponents={org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer@aadab28=98.org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer#0, org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean@aa290b3=stockInboundPoller, org.springframework.integration.transformer.MethodInvokingTransformer@e5f85cd=98.org.springframework.integration.transformer.MethodInvokingTransformer#0, 98.channel#0=98.channel#0, org.springframework.integration.config.ConsumerEndpointFactoryBean@319dff2=98.org.springframework.integration.config.ConsumerEndpointFactoryBean#0}}, id='98', inputChannel=null}' with flowId '98' is already registered.
      An existing IntegrationFlowRegistration must be destroyed before overriding.


      After my second trial where I removed the registration from the first method and only tried with the second method but nothing was sent to the FTP:



      GenericMessage [payload=BEYFEFOexportBEY.csv, headers={id=43cfc2db-41e9-0866-8e4c-8e95968189ff, timestamp=1542702869007}]
      2018-11-20 10:34:29.011 INFO 13716 --- [nio-8081-exec-6] f.s.s.configuration.FTIntegration : Outbound intermediate Channel, message=rename file:BEYFEFOexportBEY.csv









      share|improve this question















      I have created an application that adds inbound adaptors at run time for ftp servers and registers them for removing at a certain stage if needed, this app will pull a csv file from ftp server(s) and place it in my local in a folder having the name of the ftp server, so every server I add will have a separate local folder created and the csv file is saved in it, now this is accomplished smoothly, the second part is I want to change the format of that file and then send it back to the respective server, so basically I need to use outbound adaptor, in this case I would need to create outbound adaptors at run time at the same time when creating inbound adaptor or adding a server, this should be done through controller same as the inbound, I searched for possible solutions and tried a one that is below but did not work or did not perform any sending of files to destination, any solution on how I can accomplish this?
      In the configuration class I added the below:



      public IntegrationFlow ftpOutboundFlow(Branch myBranch){

      return IntegrationFlows.from(OUTBOUND_CHANNEL)
      .handle(Ftp.outboundAdapter(createNewFtpSessionFactory(myBranch), FileExistsMode.FAIL)
      .useTemporaryFileName(true)
      .remoteFileSeparator("/")
      //.fileNameExpression("BEY/FEFOexportBEY.csv")
      .remoteDirectory(myBranch.getFolderPath()))
      .get();

      }

      @MessagingGateway
      public interface MyGateway {

      @Gateway(requestChannel = OUTBOUND_CHANNEL)
      void sendToFtp(File file);

      }



      @Bean
      public IntegrationFlow ftpOutboundChannel() {

      return IntegrationFlows.from(OUTBOUND_CHANNEL)
      .publishSubscribeChannel(p -> p
      .subscribe(t -> t.handle(System.out::println)))
      /*.transform(p -> {
      LOG.info("Outbound intermediate Channel, message=rename file:" + p);
      return p;
      })*/
      .channel(new NullChannel())
      .get();
      }


      And in the Controller class



      @RequestMapping("/branch/showbranch/{id}")
      public String getBranch (@PathVariable String id, Model model){
      model.addAttribute("branch", branchService.getById(Long.valueOf(id)));
      addFlowftp(id);
      addFlowftpOutbound(id);
      return "/branch/showbranch";

      }

      private void addFlowFtp(String name) {
      branch = branchService.getById(Long.valueOf(name));
      System.out.println(branch.getBranchCode());
      IntegrationFlow flow = ftIntegration.fileInboundFlowFromFTPServer(branch);
      this.flowContext.registration(flow).id(name).register();
      }

      private void addFlowftpOutbound(String name) {
      branch = branchService.getById(Long.valueOf(name));
      System.out.println(branch.getBranchCode());
      IntegrationFlow flow = ftIntegration.ftpOutboundFlow(branch);
      // this.flowContext.registration(flow).id(name).register();
      myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));
      }


      Here is what I get in the consol as error when I enable the register before sending the file:



      java.lang.IllegalArgumentException: An IntegrationFlow 'IntegrationFlowRegistration{integrationFlow=StandardIntegrationFlow{integrationComponents={org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer@aadab28=98.org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer#0, org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean@aa290b3=stockInboundPoller, org.springframework.integration.transformer.MethodInvokingTransformer@e5f85cd=98.org.springframework.integration.transformer.MethodInvokingTransformer#0, 98.channel#0=98.channel#0, org.springframework.integration.config.ConsumerEndpointFactoryBean@319dff2=98.org.springframework.integration.config.ConsumerEndpointFactoryBean#0}}, id='98', inputChannel=null}' with flowId '98' is already registered.
      An existing IntegrationFlowRegistration must be destroyed before overriding.


      After my second trial where I removed the registration from the first method and only tried with the second method but nothing was sent to the FTP:



      GenericMessage [payload=BEYFEFOexportBEY.csv, headers={id=43cfc2db-41e9-0866-8e4c-8e95968189ff, timestamp=1542702869007}]
      2018-11-20 10:34:29.011 INFO 13716 --- [nio-8081-exec-6] f.s.s.configuration.FTIntegration : Outbound intermediate Channel, message=rename file:BEYFEFOexportBEY.csv






      spring spring-integration






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 at 8:55

























      asked Nov 19 at 8:09









      Elias Khattar

      256




      256
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          You need to perform this.flowContext.registration(flow).id(name).register(); before sending the file via myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));.



          That's first.



          Other concern I see in your code that you have a ftpOutboundChannel bean for an IntegrationFlow which is subscribed to the same OUTBOUND_CHANNEL. If that one is not declared as a PublishSubscribeChannel, then you'll end up with the round-robin distribution. And I believe you would like to have file sent to the FTP and logged. So, indeed you need to declare that channel as a PublishSubscribeChannel.



          You don't have any error because that OUTBOUND_CHANNEL has your ftpOutboundChannel IntegrationFlow as subscriber.






          share|improve this answer





















          • Thanks for the help, If I enable this.flowContext.registration(flow).id(name).register(); it is telling that the id is already registered when I add a new FTP server, this is because I have a method called addFlowFtp that is registering the server when adding it for inbound flow, so not able to do it twice, any solution for that? I updated the code as well to show the other method, I also updated method ftpOutboundChannel() to have PublishSubscribeChannel, can you please let me know that is fine now as well? some how new with Spring Integration
            – Elias Khattar
            Nov 20 at 8:09










          • I tried as well to comment the registration in the first method and ran the app, then tried to add a branch, it did not FTP the csv file to destination folder, it did not do anything, I updated at the end of the coding above with the new consol that I got@Artem Bilan
            – Elias Khattar
            Nov 20 at 8:53










          • Can you please help as well here @Gary Russell
            – Elias Khattar
            Nov 20 at 19:09










          • Your OUTBOUND_CHANNEL is not a PublishSubscribeChannel yet, so your ftpOutboundChannel() still wins to get a message from the gateway.
            – Artem Bilan
            Nov 20 at 19:13










          • Is there any example where I reference and sort my issue out?cause I'm not sure how I can make my OUTBOUND_CHANNEL as PublishSubscribeChannel although I have added it in ftpOutboundChannel()...@Artem Bilan
            – Elias Khattar
            Nov 20 at 19:36











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53370579%2fjava-outbound-adaptor-processing%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          You need to perform this.flowContext.registration(flow).id(name).register(); before sending the file via myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));.



          That's first.



          Other concern I see in your code that you have a ftpOutboundChannel bean for an IntegrationFlow which is subscribed to the same OUTBOUND_CHANNEL. If that one is not declared as a PublishSubscribeChannel, then you'll end up with the round-robin distribution. And I believe you would like to have file sent to the FTP and logged. So, indeed you need to declare that channel as a PublishSubscribeChannel.



          You don't have any error because that OUTBOUND_CHANNEL has your ftpOutboundChannel IntegrationFlow as subscriber.






          share|improve this answer





















          • Thanks for the help, If I enable this.flowContext.registration(flow).id(name).register(); it is telling that the id is already registered when I add a new FTP server, this is because I have a method called addFlowFtp that is registering the server when adding it for inbound flow, so not able to do it twice, any solution for that? I updated the code as well to show the other method, I also updated method ftpOutboundChannel() to have PublishSubscribeChannel, can you please let me know that is fine now as well? some how new with Spring Integration
            – Elias Khattar
            Nov 20 at 8:09










          • I tried as well to comment the registration in the first method and ran the app, then tried to add a branch, it did not FTP the csv file to destination folder, it did not do anything, I updated at the end of the coding above with the new consol that I got@Artem Bilan
            – Elias Khattar
            Nov 20 at 8:53










          • Can you please help as well here @Gary Russell
            – Elias Khattar
            Nov 20 at 19:09










          • Your OUTBOUND_CHANNEL is not a PublishSubscribeChannel yet, so your ftpOutboundChannel() still wins to get a message from the gateway.
            – Artem Bilan
            Nov 20 at 19:13










          • Is there any example where I reference and sort my issue out?cause I'm not sure how I can make my OUTBOUND_CHANNEL as PublishSubscribeChannel although I have added it in ftpOutboundChannel()...@Artem Bilan
            – Elias Khattar
            Nov 20 at 19:36















          up vote
          1
          down vote



          accepted










          You need to perform this.flowContext.registration(flow).id(name).register(); before sending the file via myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));.



          That's first.



          Other concern I see in your code that you have a ftpOutboundChannel bean for an IntegrationFlow which is subscribed to the same OUTBOUND_CHANNEL. If that one is not declared as a PublishSubscribeChannel, then you'll end up with the round-robin distribution. And I believe you would like to have file sent to the FTP and logged. So, indeed you need to declare that channel as a PublishSubscribeChannel.



          You don't have any error because that OUTBOUND_CHANNEL has your ftpOutboundChannel IntegrationFlow as subscriber.






          share|improve this answer





















          • Thanks for the help, If I enable this.flowContext.registration(flow).id(name).register(); it is telling that the id is already registered when I add a new FTP server, this is because I have a method called addFlowFtp that is registering the server when adding it for inbound flow, so not able to do it twice, any solution for that? I updated the code as well to show the other method, I also updated method ftpOutboundChannel() to have PublishSubscribeChannel, can you please let me know that is fine now as well? some how new with Spring Integration
            – Elias Khattar
            Nov 20 at 8:09










          • I tried as well to comment the registration in the first method and ran the app, then tried to add a branch, it did not FTP the csv file to destination folder, it did not do anything, I updated at the end of the coding above with the new consol that I got@Artem Bilan
            – Elias Khattar
            Nov 20 at 8:53










          • Can you please help as well here @Gary Russell
            – Elias Khattar
            Nov 20 at 19:09










          • Your OUTBOUND_CHANNEL is not a PublishSubscribeChannel yet, so your ftpOutboundChannel() still wins to get a message from the gateway.
            – Artem Bilan
            Nov 20 at 19:13










          • Is there any example where I reference and sort my issue out?cause I'm not sure how I can make my OUTBOUND_CHANNEL as PublishSubscribeChannel although I have added it in ftpOutboundChannel()...@Artem Bilan
            – Elias Khattar
            Nov 20 at 19:36













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          You need to perform this.flowContext.registration(flow).id(name).register(); before sending the file via myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));.



          That's first.



          Other concern I see in your code that you have a ftpOutboundChannel bean for an IntegrationFlow which is subscribed to the same OUTBOUND_CHANNEL. If that one is not declared as a PublishSubscribeChannel, then you'll end up with the round-robin distribution. And I believe you would like to have file sent to the FTP and logged. So, indeed you need to declare that channel as a PublishSubscribeChannel.



          You don't have any error because that OUTBOUND_CHANNEL has your ftpOutboundChannel IntegrationFlow as subscriber.






          share|improve this answer












          You need to perform this.flowContext.registration(flow).id(name).register(); before sending the file via myGateway.sendToFtp(new File("BEY/FEFOexportBEY.csv"));.



          That's first.



          Other concern I see in your code that you have a ftpOutboundChannel bean for an IntegrationFlow which is subscribed to the same OUTBOUND_CHANNEL. If that one is not declared as a PublishSubscribeChannel, then you'll end up with the round-robin distribution. And I believe you would like to have file sent to the FTP and logged. So, indeed you need to declare that channel as a PublishSubscribeChannel.



          You don't have any error because that OUTBOUND_CHANNEL has your ftpOutboundChannel IntegrationFlow as subscriber.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 at 14:29









          Artem Bilan

          62.9k84668




          62.9k84668












          • Thanks for the help, If I enable this.flowContext.registration(flow).id(name).register(); it is telling that the id is already registered when I add a new FTP server, this is because I have a method called addFlowFtp that is registering the server when adding it for inbound flow, so not able to do it twice, any solution for that? I updated the code as well to show the other method, I also updated method ftpOutboundChannel() to have PublishSubscribeChannel, can you please let me know that is fine now as well? some how new with Spring Integration
            – Elias Khattar
            Nov 20 at 8:09










          • I tried as well to comment the registration in the first method and ran the app, then tried to add a branch, it did not FTP the csv file to destination folder, it did not do anything, I updated at the end of the coding above with the new consol that I got@Artem Bilan
            – Elias Khattar
            Nov 20 at 8:53










          • Can you please help as well here @Gary Russell
            – Elias Khattar
            Nov 20 at 19:09










          • Your OUTBOUND_CHANNEL is not a PublishSubscribeChannel yet, so your ftpOutboundChannel() still wins to get a message from the gateway.
            – Artem Bilan
            Nov 20 at 19:13










          • Is there any example where I reference and sort my issue out?cause I'm not sure how I can make my OUTBOUND_CHANNEL as PublishSubscribeChannel although I have added it in ftpOutboundChannel()...@Artem Bilan
            – Elias Khattar
            Nov 20 at 19:36


















          • Thanks for the help, If I enable this.flowContext.registration(flow).id(name).register(); it is telling that the id is already registered when I add a new FTP server, this is because I have a method called addFlowFtp that is registering the server when adding it for inbound flow, so not able to do it twice, any solution for that? I updated the code as well to show the other method, I also updated method ftpOutboundChannel() to have PublishSubscribeChannel, can you please let me know that is fine now as well? some how new with Spring Integration
            – Elias Khattar
            Nov 20 at 8:09










          • I tried as well to comment the registration in the first method and ran the app, then tried to add a branch, it did not FTP the csv file to destination folder, it did not do anything, I updated at the end of the coding above with the new consol that I got@Artem Bilan
            – Elias Khattar
            Nov 20 at 8:53










          • Can you please help as well here @Gary Russell
            – Elias Khattar
            Nov 20 at 19:09










          • Your OUTBOUND_CHANNEL is not a PublishSubscribeChannel yet, so your ftpOutboundChannel() still wins to get a message from the gateway.
            – Artem Bilan
            Nov 20 at 19:13










          • Is there any example where I reference and sort my issue out?cause I'm not sure how I can make my OUTBOUND_CHANNEL as PublishSubscribeChannel although I have added it in ftpOutboundChannel()...@Artem Bilan
            – Elias Khattar
            Nov 20 at 19:36
















          Thanks for the help, If I enable this.flowContext.registration(flow).id(name).register(); it is telling that the id is already registered when I add a new FTP server, this is because I have a method called addFlowFtp that is registering the server when adding it for inbound flow, so not able to do it twice, any solution for that? I updated the code as well to show the other method, I also updated method ftpOutboundChannel() to have PublishSubscribeChannel, can you please let me know that is fine now as well? some how new with Spring Integration
          – Elias Khattar
          Nov 20 at 8:09




          Thanks for the help, If I enable this.flowContext.registration(flow).id(name).register(); it is telling that the id is already registered when I add a new FTP server, this is because I have a method called addFlowFtp that is registering the server when adding it for inbound flow, so not able to do it twice, any solution for that? I updated the code as well to show the other method, I also updated method ftpOutboundChannel() to have PublishSubscribeChannel, can you please let me know that is fine now as well? some how new with Spring Integration
          – Elias Khattar
          Nov 20 at 8:09












          I tried as well to comment the registration in the first method and ran the app, then tried to add a branch, it did not FTP the csv file to destination folder, it did not do anything, I updated at the end of the coding above with the new consol that I got@Artem Bilan
          – Elias Khattar
          Nov 20 at 8:53




          I tried as well to comment the registration in the first method and ran the app, then tried to add a branch, it did not FTP the csv file to destination folder, it did not do anything, I updated at the end of the coding above with the new consol that I got@Artem Bilan
          – Elias Khattar
          Nov 20 at 8:53












          Can you please help as well here @Gary Russell
          – Elias Khattar
          Nov 20 at 19:09




          Can you please help as well here @Gary Russell
          – Elias Khattar
          Nov 20 at 19:09












          Your OUTBOUND_CHANNEL is not a PublishSubscribeChannel yet, so your ftpOutboundChannel() still wins to get a message from the gateway.
          – Artem Bilan
          Nov 20 at 19:13




          Your OUTBOUND_CHANNEL is not a PublishSubscribeChannel yet, so your ftpOutboundChannel() still wins to get a message from the gateway.
          – Artem Bilan
          Nov 20 at 19:13












          Is there any example where I reference and sort my issue out?cause I'm not sure how I can make my OUTBOUND_CHANNEL as PublishSubscribeChannel although I have added it in ftpOutboundChannel()...@Artem Bilan
          – Elias Khattar
          Nov 20 at 19:36




          Is there any example where I reference and sort my issue out?cause I'm not sure how I can make my OUTBOUND_CHANNEL as PublishSubscribeChannel although I have added it in ftpOutboundChannel()...@Artem Bilan
          – Elias Khattar
          Nov 20 at 19:36


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53370579%2fjava-outbound-adaptor-processing%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          RAC Tourist Trophy