Save some information in the payload with the claim validation template?

I am reading about Check Validation in Spring Integration.

When using this template, it sounds as if all the payload is placed in the message store, and the resulting payload is just the request validation identifier.

Does Spring provide an easy way to store the payload in the message store, while preserving certain parts of the payload? Do you need to use the header first and save the properties you want to access in the header?

For example, let's say my payload is a simple XML document:

<payload>
    <cc>1234432156788765</cc>
    <or>5799</or>
</payload>

I want to require checking this payload, but still retain access to the element payload.or. How can this be done using current Spring integration components?

+4
source share
1 answer

The main goal Claim Checkis to save the message and not worry about its size, since the message can move through several external systems. It can also be restored after a system failure.

The best example from the real world is baggage. During transfers, you only have a receipt and luggage at the end.

To achieve your goal, I suggest you use <enricher>:

<int:enricher request-channel="claimCheckInChannel">
   <int:header name="claimCheck" expression="payload"/>
</int:enricher>

<claim-check-in input-channel="claimCheckInChannel" message-store="messageStore"/>

payload id.

. message , payload. org.springframework.integration.transformer.ClaimCheckInTransformer:

@Override
protected Object doTransform(Message<?> message) throws Exception {
    Assert.notNull(message, "message must not be null");
    Object payload = message.getPayload();
    Assert.notNull(payload, "payload must not be null");
    Message<?> storedMessage = this.messageStore.addMessage(message);
    MessageBuilder<?> responseBuilder = MessageBuilder.withPayload(storedMessage.getHeaders().getId());
    // headers on the 'current' message take precedence
    responseBuilder.copyHeaders(message.getHeaders());
    return responseBuilder.build();
}
+4

Source: https://habr.com/ru/post/1537545/


All Articles