title: Is it possible to overwrite the value of the message header id in spring integration?
body: <p>I am using the claim check pattern from <a href="/questions/tagged/spring-integration" class="post-tag" title="show questions tagged 'spring-integration'" rel="tag">spring-integration</a>, but I would like to have the message stored with a custom ID. This should be easy, as the message store implementations are using the incoming message header id to store the message. Is it possible to overwrite the value of the message header id using a header enricher or/and a header filter? <br/></p>
  
  <h2>Message header id and the message store</h2>
  
  <p>The <code>SimpleMessageStore</code>, as well as the <code>JdbcMessageStore</code>, are using the incoming message ID to store the message. In the <code>addMessage</code> method (the example is from the <code>SimpleMessageStore</code>) we have:</p>
  
  <pre><code>this.idToMessage.put(message.getHeaders().getId(), message); 
  </code></pre>
  
  <p>To have a custom ID it should be enough to have a header enricher before claim check in, where the value of the id header is replaced with a custom value. For example:</p>
  
  <pre><code>&lt;int:header-enricher input-channel="gateDocCheckInReqChannel" 
      output-channel="gateDocCheckInEnrichedChannel"&gt;
      &lt;int:header name="id" expression="payload.getDocumentID()" overwrite="true" /&gt;
  &lt;/int:header-enricher&gt;
  &lt;int:claim-check-in input-channel="gateDocCheckInEnrichedChannel" 
      output-channel="gateDocCheckInReplyChannel" message-store="messageStore" /&gt;
  </code></pre>
  
  <p>It does not work; the message header id is not overwritten. I tried having a header filter on ID before the header enricher, but it does not work either. <br/></p>
  
  <h2>Related</h2>
  
  <p>I found this old post on removing the headers fields that is undone by some internal logic: <br/>
  <a href="http://forum.spring.io/forum/spring-projects/integration/74099-remove-header-fields" rel="nofollow">http://forum.spring.io/forum/spring-projects/integration/74099-remove-header-fields</a> <br/>
  Also, there is this closed issue INT-923 on a message handler that undoes header removals. <br/>
  <a href="https://jira.spring.io/browse/INT-923" rel="nofollow">https://jira.spring.io/browse/INT-923</a> <br/>
  It is supposed that issue INT-1135 on header filters fixes this behavior. <br/>
  <a href="https://jira.spring.io/browse/INT-1135" rel="nofollow">https://jira.spring.io/browse/INT-1135</a> </p>