Looping channel to update the header enricher to place file in multiple targets












0














Trying to place a file in multiple directories using single outbound gateway using spring-integration-file.I Know that it's not possible with such a channel adapter to send to several directories at a time.



In order to achieve that, having a loop in front of the file:outbound-gateway to modify message header target directory on each iteration and send all of them to the same channel again and again.



But getting exception as mentioned below.



Any suggestion how to loop it or update the header and execute the adapter again



file : Outbound gateway:



<!-- header enricher -->
<integration:header-enricher input-channel="filesHeaderEnricherChannel" output-channel="filesOut">
<integration:header name="TARGET_COUNT" method="getTargetCount" ref="headerEnricher"/>
<integration:header name="TARGET_DIR" method="getTargetPath" ref="headerEnricher"/>
</integration:header-enricher>

<integration:chain id="filesOutChain" input-channel="filesOut">
<integration:transformer expression="headers.FILE"/>
<file:outbound-adapter id="fileMover"
auto-create-directory="true"
directory-expression="headers.TARGET_DIR"
mode="REPLACE">
<file:request-handler-advice-chain>
<ref bean="retryAdvice" />
</file:request-handler-advice-chain>
</file:outbound-adapter>
</integration:chain>

<!-- decreasing the count on each loop -->
<!-- looping to header enricher channel again as output channel to update the target directory -->
<integration:filter input-channel="filesOut" expression="headers.TARGET_COUNT != 0" output-channel="filesHeaderEnricherChannel"
discard-channel="filesArchiveChannel" throw-exception-on-rejection="true">
<integration:request-handler-advice-chain>
<ref bean="retryAdvice" />
</integration:request-handler-advice-chain>
</<integration:filter>









share|improve this question





























    0














    Trying to place a file in multiple directories using single outbound gateway using spring-integration-file.I Know that it's not possible with such a channel adapter to send to several directories at a time.



    In order to achieve that, having a loop in front of the file:outbound-gateway to modify message header target directory on each iteration and send all of them to the same channel again and again.



    But getting exception as mentioned below.



    Any suggestion how to loop it or update the header and execute the adapter again



    file : Outbound gateway:



    <!-- header enricher -->
    <integration:header-enricher input-channel="filesHeaderEnricherChannel" output-channel="filesOut">
    <integration:header name="TARGET_COUNT" method="getTargetCount" ref="headerEnricher"/>
    <integration:header name="TARGET_DIR" method="getTargetPath" ref="headerEnricher"/>
    </integration:header-enricher>

    <integration:chain id="filesOutChain" input-channel="filesOut">
    <integration:transformer expression="headers.FILE"/>
    <file:outbound-adapter id="fileMover"
    auto-create-directory="true"
    directory-expression="headers.TARGET_DIR"
    mode="REPLACE">
    <file:request-handler-advice-chain>
    <ref bean="retryAdvice" />
    </file:request-handler-advice-chain>
    </file:outbound-adapter>
    </integration:chain>

    <!-- decreasing the count on each loop -->
    <!-- looping to header enricher channel again as output channel to update the target directory -->
    <integration:filter input-channel="filesOut" expression="headers.TARGET_COUNT != 0" output-channel="filesHeaderEnricherChannel"
    discard-channel="filesArchiveChannel" throw-exception-on-rejection="true">
    <integration:request-handler-advice-chain>
    <ref bean="retryAdvice" />
    </integration:request-handler-advice-chain>
    </<integration:filter>









    share|improve this question



























      0












      0








      0







      Trying to place a file in multiple directories using single outbound gateway using spring-integration-file.I Know that it's not possible with such a channel adapter to send to several directories at a time.



      In order to achieve that, having a loop in front of the file:outbound-gateway to modify message header target directory on each iteration and send all of them to the same channel again and again.



      But getting exception as mentioned below.



      Any suggestion how to loop it or update the header and execute the adapter again



      file : Outbound gateway:



      <!-- header enricher -->
      <integration:header-enricher input-channel="filesHeaderEnricherChannel" output-channel="filesOut">
      <integration:header name="TARGET_COUNT" method="getTargetCount" ref="headerEnricher"/>
      <integration:header name="TARGET_DIR" method="getTargetPath" ref="headerEnricher"/>
      </integration:header-enricher>

      <integration:chain id="filesOutChain" input-channel="filesOut">
      <integration:transformer expression="headers.FILE"/>
      <file:outbound-adapter id="fileMover"
      auto-create-directory="true"
      directory-expression="headers.TARGET_DIR"
      mode="REPLACE">
      <file:request-handler-advice-chain>
      <ref bean="retryAdvice" />
      </file:request-handler-advice-chain>
      </file:outbound-adapter>
      </integration:chain>

      <!-- decreasing the count on each loop -->
      <!-- looping to header enricher channel again as output channel to update the target directory -->
      <integration:filter input-channel="filesOut" expression="headers.TARGET_COUNT != 0" output-channel="filesHeaderEnricherChannel"
      discard-channel="filesArchiveChannel" throw-exception-on-rejection="true">
      <integration:request-handler-advice-chain>
      <ref bean="retryAdvice" />
      </integration:request-handler-advice-chain>
      </<integration:filter>









      share|improve this question















      Trying to place a file in multiple directories using single outbound gateway using spring-integration-file.I Know that it's not possible with such a channel adapter to send to several directories at a time.



      In order to achieve that, having a loop in front of the file:outbound-gateway to modify message header target directory on each iteration and send all of them to the same channel again and again.



      But getting exception as mentioned below.



      Any suggestion how to loop it or update the header and execute the adapter again



      file : Outbound gateway:



      <!-- header enricher -->
      <integration:header-enricher input-channel="filesHeaderEnricherChannel" output-channel="filesOut">
      <integration:header name="TARGET_COUNT" method="getTargetCount" ref="headerEnricher"/>
      <integration:header name="TARGET_DIR" method="getTargetPath" ref="headerEnricher"/>
      </integration:header-enricher>

      <integration:chain id="filesOutChain" input-channel="filesOut">
      <integration:transformer expression="headers.FILE"/>
      <file:outbound-adapter id="fileMover"
      auto-create-directory="true"
      directory-expression="headers.TARGET_DIR"
      mode="REPLACE">
      <file:request-handler-advice-chain>
      <ref bean="retryAdvice" />
      </file:request-handler-advice-chain>
      </file:outbound-adapter>
      </integration:chain>

      <!-- decreasing the count on each loop -->
      <!-- looping to header enricher channel again as output channel to update the target directory -->
      <integration:filter input-channel="filesOut" expression="headers.TARGET_COUNT != 0" output-channel="filesHeaderEnricherChannel"
      discard-channel="filesArchiveChannel" throw-exception-on-rejection="true">
      <integration:request-handler-advice-chain>
      <ref bean="retryAdvice" />
      </integration:request-handler-advice-chain>
      </<integration:filter>






      spring spring-mvc spring-integration spring-integration-sftp spring-integration-aws






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 15:38

























      asked Nov 12 '18 at 13:10









      Jessie

      4484820




      4484820
























          1 Answer
          1






          active

          oldest

          votes


















          1














          You don't need to have a <integration:gateway request-channel="filesOutChainChannel" in the end of your chain. you should just configure a chain to output into the filesOutChainChannel and there in the filter it seems you do right things.



          The problem with the gateway that it waits for reply, but since you loop it into the filesHeaderEnricherChannel back you grow the call stack with with waiting gateways again and again.






          share|improve this answer





















          • have tried your solution. am not getting the call stack exception now after replaced the gateway with adapter. But the call doesnot go back to the loop "filesHeaderEnricherChannel". attached edited code above for your reference.
            – Jessie
            Nov 13 '18 at 15:39










          • Looks like you didn't understand me and did a big mistake in your config. Now you have to round-robin subscribers on the filesOut channel. My point was to have an outpup-channel on the chain, however I see you have changed a gateway to the ` <file:outbound-adapter>, so you are not going to wait for reply. That's fine too. so, consider to make that filesOut` as <publish-subscribe-channel>. Also not sure why do you need a retryAdvice on that filter...
            – Artem Bilan
            Nov 13 '18 at 16:30










          • Am sorry. Got your point now. Asked me to add output - channel for integration:chain...will try it...just need a confirmation...after adding...will it loop back to "filesHeaderEnricherChannel"...is it possible to do loop back to channel which is above the code?
            – Jessie
            Nov 13 '18 at 16:39










          • That's fully doesn't matter: in the end you have some objects in the memory you interact with. The config is fully not related there at all.
            – Artem Bilan
            Nov 13 '18 at 16:40











          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',
          autoActivateHeartbeat: false,
          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%2f53262892%2flooping-channel-to-update-the-header-enricher-to-place-file-in-multiple-targets%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









          1














          You don't need to have a <integration:gateway request-channel="filesOutChainChannel" in the end of your chain. you should just configure a chain to output into the filesOutChainChannel and there in the filter it seems you do right things.



          The problem with the gateway that it waits for reply, but since you loop it into the filesHeaderEnricherChannel back you grow the call stack with with waiting gateways again and again.






          share|improve this answer





















          • have tried your solution. am not getting the call stack exception now after replaced the gateway with adapter. But the call doesnot go back to the loop "filesHeaderEnricherChannel". attached edited code above for your reference.
            – Jessie
            Nov 13 '18 at 15:39










          • Looks like you didn't understand me and did a big mistake in your config. Now you have to round-robin subscribers on the filesOut channel. My point was to have an outpup-channel on the chain, however I see you have changed a gateway to the ` <file:outbound-adapter>, so you are not going to wait for reply. That's fine too. so, consider to make that filesOut` as <publish-subscribe-channel>. Also not sure why do you need a retryAdvice on that filter...
            – Artem Bilan
            Nov 13 '18 at 16:30










          • Am sorry. Got your point now. Asked me to add output - channel for integration:chain...will try it...just need a confirmation...after adding...will it loop back to "filesHeaderEnricherChannel"...is it possible to do loop back to channel which is above the code?
            – Jessie
            Nov 13 '18 at 16:39










          • That's fully doesn't matter: in the end you have some objects in the memory you interact with. The config is fully not related there at all.
            – Artem Bilan
            Nov 13 '18 at 16:40
















          1














          You don't need to have a <integration:gateway request-channel="filesOutChainChannel" in the end of your chain. you should just configure a chain to output into the filesOutChainChannel and there in the filter it seems you do right things.



          The problem with the gateway that it waits for reply, but since you loop it into the filesHeaderEnricherChannel back you grow the call stack with with waiting gateways again and again.






          share|improve this answer





















          • have tried your solution. am not getting the call stack exception now after replaced the gateway with adapter. But the call doesnot go back to the loop "filesHeaderEnricherChannel". attached edited code above for your reference.
            – Jessie
            Nov 13 '18 at 15:39










          • Looks like you didn't understand me and did a big mistake in your config. Now you have to round-robin subscribers on the filesOut channel. My point was to have an outpup-channel on the chain, however I see you have changed a gateway to the ` <file:outbound-adapter>, so you are not going to wait for reply. That's fine too. so, consider to make that filesOut` as <publish-subscribe-channel>. Also not sure why do you need a retryAdvice on that filter...
            – Artem Bilan
            Nov 13 '18 at 16:30










          • Am sorry. Got your point now. Asked me to add output - channel for integration:chain...will try it...just need a confirmation...after adding...will it loop back to "filesHeaderEnricherChannel"...is it possible to do loop back to channel which is above the code?
            – Jessie
            Nov 13 '18 at 16:39










          • That's fully doesn't matter: in the end you have some objects in the memory you interact with. The config is fully not related there at all.
            – Artem Bilan
            Nov 13 '18 at 16:40














          1












          1








          1






          You don't need to have a <integration:gateway request-channel="filesOutChainChannel" in the end of your chain. you should just configure a chain to output into the filesOutChainChannel and there in the filter it seems you do right things.



          The problem with the gateway that it waits for reply, but since you loop it into the filesHeaderEnricherChannel back you grow the call stack with with waiting gateways again and again.






          share|improve this answer












          You don't need to have a <integration:gateway request-channel="filesOutChainChannel" in the end of your chain. you should just configure a chain to output into the filesOutChainChannel and there in the filter it seems you do right things.



          The problem with the gateway that it waits for reply, but since you loop it into the filesHeaderEnricherChannel back you grow the call stack with with waiting gateways again and again.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 14:37









          Artem Bilan

          63.9k84668




          63.9k84668












          • have tried your solution. am not getting the call stack exception now after replaced the gateway with adapter. But the call doesnot go back to the loop "filesHeaderEnricherChannel". attached edited code above for your reference.
            – Jessie
            Nov 13 '18 at 15:39










          • Looks like you didn't understand me and did a big mistake in your config. Now you have to round-robin subscribers on the filesOut channel. My point was to have an outpup-channel on the chain, however I see you have changed a gateway to the ` <file:outbound-adapter>, so you are not going to wait for reply. That's fine too. so, consider to make that filesOut` as <publish-subscribe-channel>. Also not sure why do you need a retryAdvice on that filter...
            – Artem Bilan
            Nov 13 '18 at 16:30










          • Am sorry. Got your point now. Asked me to add output - channel for integration:chain...will try it...just need a confirmation...after adding...will it loop back to "filesHeaderEnricherChannel"...is it possible to do loop back to channel which is above the code?
            – Jessie
            Nov 13 '18 at 16:39










          • That's fully doesn't matter: in the end you have some objects in the memory you interact with. The config is fully not related there at all.
            – Artem Bilan
            Nov 13 '18 at 16:40


















          • have tried your solution. am not getting the call stack exception now after replaced the gateway with adapter. But the call doesnot go back to the loop "filesHeaderEnricherChannel". attached edited code above for your reference.
            – Jessie
            Nov 13 '18 at 15:39










          • Looks like you didn't understand me and did a big mistake in your config. Now you have to round-robin subscribers on the filesOut channel. My point was to have an outpup-channel on the chain, however I see you have changed a gateway to the ` <file:outbound-adapter>, so you are not going to wait for reply. That's fine too. so, consider to make that filesOut` as <publish-subscribe-channel>. Also not sure why do you need a retryAdvice on that filter...
            – Artem Bilan
            Nov 13 '18 at 16:30










          • Am sorry. Got your point now. Asked me to add output - channel for integration:chain...will try it...just need a confirmation...after adding...will it loop back to "filesHeaderEnricherChannel"...is it possible to do loop back to channel which is above the code?
            – Jessie
            Nov 13 '18 at 16:39










          • That's fully doesn't matter: in the end you have some objects in the memory you interact with. The config is fully not related there at all.
            – Artem Bilan
            Nov 13 '18 at 16:40
















          have tried your solution. am not getting the call stack exception now after replaced the gateway with adapter. But the call doesnot go back to the loop "filesHeaderEnricherChannel". attached edited code above for your reference.
          – Jessie
          Nov 13 '18 at 15:39




          have tried your solution. am not getting the call stack exception now after replaced the gateway with adapter. But the call doesnot go back to the loop "filesHeaderEnricherChannel". attached edited code above for your reference.
          – Jessie
          Nov 13 '18 at 15:39












          Looks like you didn't understand me and did a big mistake in your config. Now you have to round-robin subscribers on the filesOut channel. My point was to have an outpup-channel on the chain, however I see you have changed a gateway to the ` <file:outbound-adapter>, so you are not going to wait for reply. That's fine too. so, consider to make that filesOut` as <publish-subscribe-channel>. Also not sure why do you need a retryAdvice on that filter...
          – Artem Bilan
          Nov 13 '18 at 16:30




          Looks like you didn't understand me and did a big mistake in your config. Now you have to round-robin subscribers on the filesOut channel. My point was to have an outpup-channel on the chain, however I see you have changed a gateway to the ` <file:outbound-adapter>, so you are not going to wait for reply. That's fine too. so, consider to make that filesOut` as <publish-subscribe-channel>. Also not sure why do you need a retryAdvice on that filter...
          – Artem Bilan
          Nov 13 '18 at 16:30












          Am sorry. Got your point now. Asked me to add output - channel for integration:chain...will try it...just need a confirmation...after adding...will it loop back to "filesHeaderEnricherChannel"...is it possible to do loop back to channel which is above the code?
          – Jessie
          Nov 13 '18 at 16:39




          Am sorry. Got your point now. Asked me to add output - channel for integration:chain...will try it...just need a confirmation...after adding...will it loop back to "filesHeaderEnricherChannel"...is it possible to do loop back to channel which is above the code?
          – Jessie
          Nov 13 '18 at 16:39












          That's fully doesn't matter: in the end you have some objects in the memory you interact with. The config is fully not related there at all.
          – Artem Bilan
          Nov 13 '18 at 16:40




          That's fully doesn't matter: in the end you have some objects in the memory you interact with. The config is fully not related there at all.
          – Artem Bilan
          Nov 13 '18 at 16:40


















          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%2f53262892%2flooping-channel-to-update-the-header-enricher-to-place-file-in-multiple-targets%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

          Florida Star v. B. J. F.

          Error while running script in elastic search , gateway timeout

          Adding quotations to stringified JSON object values