0
votes

I have a huge xml that come as an input payload to my Spring integration flow. So I am using claim check in transformer instead of header enricher to retain my payload. I am using an in-memory message store.

Later on in my SI flow, I have a splitter that splits the payload into multiple threads and each thread will invoke different channel based on one of the attribute payload. I am using a router for achieve this. Each flow or each thread uses a claim check out transformer to retrieve the initial payload then us it for building the required response. Each thread will produce a response and I don't have to aggregate them. So I will have multiple responses coming out from my flow which will then be dropped into a queue.

I cannot remove the message during the check out as other thread will also try to check out the same message. What is the best way to remove the message from the message store?

Sample configuration

`<int:chain input-channel="myInputChannel"
    output-channel="myOutputchannel">
    <int:claim-check-in />
    <int:header-enricher>
        <int:header name="myClaimCheckID" expression="payload"/>
    </int:header-enricher>
 </int:chain>`

all the other components in the flow are invoked before the splitter

<int:splitter input-channel="mySplitterChannel" output-channel="myRouterChannel" expression="mySplitExpression"> </int:splitter>

`<int:router input-channel="myRouterChannel" expression="routerExpression"
    resolution-required="true">
    <int:mapping value="A" channel="aChannel" />
    <int:mapping value="B" channel="bChannel" />
    <int:mapping value="C" channel="cChannel" />
</int:router>`

Each channel has a claim check out transformer for the initial payload. So how do I make sure the message is removed after all the threads have been processed?

1

1 Answers

0
votes

When you know you are done with the message you can simply invoke the message store's remove() method. You could use a service activator with

... expression="@store.remove(headers['myClaimCheckID'])" ...

However, if you are using an in-memory message store there is really no point in using the claim check pattern.

If you simply promote the payload to a header, it will use no more memory than putting it in a store.

Even if it ends up in multiple messages on multiple threads, it makes no difference since they'll all be pointing to the same object on the heap.