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







      Jessie

















      asked Nov 12 '18 at 13:10









      JessieJessie

      45341021




      45341021






















          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 BilanArtem Bilan

          66.3k84971




          66.3k84971












          • 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.




          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

          𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

          How do I collapse sections of code in Visual Studio Code for Windows?

          ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ