Spring integration : Facing issue while updating the header value again












1















Trying to place a file in multiple directories using single outbound adapter using spring-integration-file.



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 till the target count decreases to 0.



Able to loop back to the header enricher channel.but Since we are enriching the header value for the same header name again. the value is not getting updated for header name TARGET_DIR. There is no exception also.



Would like to know some solution if its possible to update the header value again and again for the same header name or is it possible to give the dynamic header name at runtime.



Have tried to delete the TARGET_DIR header using header:filter while looping back. But did not work out.



 !-- 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" output-channel="filesOutChainChannel">
<integration:transformer expression="headers.FILE"/>
<file:outbound-channel-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-channel-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="filesOutChainChannel" expression="headers.TARGET_COUNT != 0" output-channel="filesHeaderEnricherChannel"
discard-channel="filesArchiveChannel">
</<integration:filter>









share|improve this question



























    1















    Trying to place a file in multiple directories using single outbound adapter using spring-integration-file.



    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 till the target count decreases to 0.



    Able to loop back to the header enricher channel.but Since we are enriching the header value for the same header name again. the value is not getting updated for header name TARGET_DIR. There is no exception also.



    Would like to know some solution if its possible to update the header value again and again for the same header name or is it possible to give the dynamic header name at runtime.



    Have tried to delete the TARGET_DIR header using header:filter while looping back. But did not work out.



     !-- 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" output-channel="filesOutChainChannel">
    <integration:transformer expression="headers.FILE"/>
    <file:outbound-channel-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-channel-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="filesOutChainChannel" expression="headers.TARGET_COUNT != 0" output-channel="filesHeaderEnricherChannel"
    discard-channel="filesArchiveChannel">
    </<integration:filter>









    share|improve this question

























      1












      1








      1








      Trying to place a file in multiple directories using single outbound adapter using spring-integration-file.



      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 till the target count decreases to 0.



      Able to loop back to the header enricher channel.but Since we are enriching the header value for the same header name again. the value is not getting updated for header name TARGET_DIR. There is no exception also.



      Would like to know some solution if its possible to update the header value again and again for the same header name or is it possible to give the dynamic header name at runtime.



      Have tried to delete the TARGET_DIR header using header:filter while looping back. But did not work out.



       !-- 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" output-channel="filesOutChainChannel">
      <integration:transformer expression="headers.FILE"/>
      <file:outbound-channel-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-channel-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="filesOutChainChannel" expression="headers.TARGET_COUNT != 0" output-channel="filesHeaderEnricherChannel"
      discard-channel="filesArchiveChannel">
      </<integration:filter>









      share|improve this question














      Trying to place a file in multiple directories using single outbound adapter using spring-integration-file.



      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 till the target count decreases to 0.



      Able to loop back to the header enricher channel.but Since we are enriching the header value for the same header name again. the value is not getting updated for header name TARGET_DIR. There is no exception also.



      Would like to know some solution if its possible to update the header value again and again for the same header name or is it possible to give the dynamic header name at runtime.



      Have tried to delete the TARGET_DIR header using header:filter while looping back. But did not work out.



       !-- 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" output-channel="filesOutChainChannel">
      <integration:transformer expression="headers.FILE"/>
      <file:outbound-channel-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-channel-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="filesOutChainChannel" expression="headers.TARGET_COUNT != 0" output-channel="filesHeaderEnricherChannel"
      discard-channel="filesArchiveChannel">
      </<integration:filter>






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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 15:18









      JessieJessie

      4534921




      4534921
























          1 Answer
          1






          active

          oldest

          votes


















          2














          You are missing the fact that header-enricher has an extra option:



              <xsd:attribute name="default-overwrite">
          <xsd:annotation>
          <xsd:documentation>
          Specify the default boolean value for whether to overwrite existing
          header values. This will
          only
          take effect for
          sub-elements that do not provide their own 'overwrite' attribute. If the
          'default-overwrite'
          attribute is not
          provided, then the specified header values will NOT overwrite any
          existing ones with the same
          header
          names.
          </xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
          <xsd:union memberTypes="xsd:boolean xsd:string" />
          </xsd:simpleType>
          </xsd:attribute>


          As well as the sub-element header has its own:



              <xsd:attribute name="overwrite">
          <xsd:annotation>
          <xsd:documentation>
          Boolean value to indicate whether this header value should overwrite an
          existing header value for
          the same name.
          </xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
          <xsd:union memberTypes="xsd:boolean xsd:string" />
          </xsd:simpleType>
          </xsd:attribute>


          See also docs on the matter: https://docs.spring.io/spring-integration/reference/html/messaging-transformation-chapter.html#header-enricher






          share|improve this answer
























          • Perfect. Worked!

            – Jessie
            Nov 16 '18 at 12:30











          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%2f53303422%2fspring-integration-facing-issue-while-updating-the-header-value-again%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









          2














          You are missing the fact that header-enricher has an extra option:



              <xsd:attribute name="default-overwrite">
          <xsd:annotation>
          <xsd:documentation>
          Specify the default boolean value for whether to overwrite existing
          header values. This will
          only
          take effect for
          sub-elements that do not provide their own 'overwrite' attribute. If the
          'default-overwrite'
          attribute is not
          provided, then the specified header values will NOT overwrite any
          existing ones with the same
          header
          names.
          </xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
          <xsd:union memberTypes="xsd:boolean xsd:string" />
          </xsd:simpleType>
          </xsd:attribute>


          As well as the sub-element header has its own:



              <xsd:attribute name="overwrite">
          <xsd:annotation>
          <xsd:documentation>
          Boolean value to indicate whether this header value should overwrite an
          existing header value for
          the same name.
          </xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
          <xsd:union memberTypes="xsd:boolean xsd:string" />
          </xsd:simpleType>
          </xsd:attribute>


          See also docs on the matter: https://docs.spring.io/spring-integration/reference/html/messaging-transformation-chapter.html#header-enricher






          share|improve this answer
























          • Perfect. Worked!

            – Jessie
            Nov 16 '18 at 12:30
















          2














          You are missing the fact that header-enricher has an extra option:



              <xsd:attribute name="default-overwrite">
          <xsd:annotation>
          <xsd:documentation>
          Specify the default boolean value for whether to overwrite existing
          header values. This will
          only
          take effect for
          sub-elements that do not provide their own 'overwrite' attribute. If the
          'default-overwrite'
          attribute is not
          provided, then the specified header values will NOT overwrite any
          existing ones with the same
          header
          names.
          </xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
          <xsd:union memberTypes="xsd:boolean xsd:string" />
          </xsd:simpleType>
          </xsd:attribute>


          As well as the sub-element header has its own:



              <xsd:attribute name="overwrite">
          <xsd:annotation>
          <xsd:documentation>
          Boolean value to indicate whether this header value should overwrite an
          existing header value for
          the same name.
          </xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
          <xsd:union memberTypes="xsd:boolean xsd:string" />
          </xsd:simpleType>
          </xsd:attribute>


          See also docs on the matter: https://docs.spring.io/spring-integration/reference/html/messaging-transformation-chapter.html#header-enricher






          share|improve this answer
























          • Perfect. Worked!

            – Jessie
            Nov 16 '18 at 12:30














          2












          2








          2







          You are missing the fact that header-enricher has an extra option:



              <xsd:attribute name="default-overwrite">
          <xsd:annotation>
          <xsd:documentation>
          Specify the default boolean value for whether to overwrite existing
          header values. This will
          only
          take effect for
          sub-elements that do not provide their own 'overwrite' attribute. If the
          'default-overwrite'
          attribute is not
          provided, then the specified header values will NOT overwrite any
          existing ones with the same
          header
          names.
          </xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
          <xsd:union memberTypes="xsd:boolean xsd:string" />
          </xsd:simpleType>
          </xsd:attribute>


          As well as the sub-element header has its own:



              <xsd:attribute name="overwrite">
          <xsd:annotation>
          <xsd:documentation>
          Boolean value to indicate whether this header value should overwrite an
          existing header value for
          the same name.
          </xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
          <xsd:union memberTypes="xsd:boolean xsd:string" />
          </xsd:simpleType>
          </xsd:attribute>


          See also docs on the matter: https://docs.spring.io/spring-integration/reference/html/messaging-transformation-chapter.html#header-enricher






          share|improve this answer













          You are missing the fact that header-enricher has an extra option:



              <xsd:attribute name="default-overwrite">
          <xsd:annotation>
          <xsd:documentation>
          Specify the default boolean value for whether to overwrite existing
          header values. This will
          only
          take effect for
          sub-elements that do not provide their own 'overwrite' attribute. If the
          'default-overwrite'
          attribute is not
          provided, then the specified header values will NOT overwrite any
          existing ones with the same
          header
          names.
          </xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
          <xsd:union memberTypes="xsd:boolean xsd:string" />
          </xsd:simpleType>
          </xsd:attribute>


          As well as the sub-element header has its own:



              <xsd:attribute name="overwrite">
          <xsd:annotation>
          <xsd:documentation>
          Boolean value to indicate whether this header value should overwrite an
          existing header value for
          the same name.
          </xsd:documentation>
          </xsd:annotation>
          <xsd:simpleType>
          <xsd:union memberTypes="xsd:boolean xsd:string" />
          </xsd:simpleType>
          </xsd:attribute>


          See also docs on the matter: https://docs.spring.io/spring-integration/reference/html/messaging-transformation-chapter.html#header-enricher







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 15:23









          Artem BilanArtem Bilan

          65.6k84668




          65.6k84668













          • Perfect. Worked!

            – Jessie
            Nov 16 '18 at 12:30



















          • Perfect. Worked!

            – Jessie
            Nov 16 '18 at 12:30

















          Perfect. Worked!

          – Jessie
          Nov 16 '18 at 12:30





          Perfect. Worked!

          – Jessie
          Nov 16 '18 at 12:30




















          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%2f53303422%2fspring-integration-facing-issue-while-updating-the-header-value-again%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

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python