I am using the claim check pattern from spring-integration, 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?
Message header id and the message store
The SimpleMessageStore
, as well as the JdbcMessageStore
, are using the incoming message ID to store the message. In the addMessage
method (the example is from the SimpleMessageStore
) we have:
this.idToMessage.put(message.getHeaders().getId(), message);
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:
<int:header-enricher input-channel="gateDocCheckInReqChannel"
output-channel="gateDocCheckInEnrichedChannel">
<int:header name="id" expression="payload.getDocumentID()" overwrite="true" />
</int:header-enricher>
<int:claim-check-in input-channel="gateDocCheckInEnrichedChannel"
output-channel="gateDocCheckInReplyChannel" message-store="messageStore" />
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.
Related
I found this old post on removing the headers fields that is undone by some internal logic:
http://forum.spring.io/forum/spring-projects/integration/74099-remove-header-fields
Also, there is this closed issue INT-923 on a message handler that undoes header removals.
https://jira.spring.io/browse/INT-923
It is supposed that issue INT-1135 on header filters fixes this behavior.
https://jira.spring.io/browse/INT-1135