1
votes

I am using Spring Integration to send a SOAP Request, receive the SOAP Response, and process it. I am also using (or trying to use) the Claim Check pattern to store the original SOAP Request and Response, in an Object, a simple POJO, called ExchangeMessage, which looks like this:

public class ExchangeMessage {

  protected String request;
  protected String response;
  ...

This is what my flow currently looks like:

(1) <int:transformer input-channel="transformerChannel" output-channel="requestChannel"/>
(2) <int:gateway default-request-channel="transformerChannel" />

<int:chain input-channel="requestChannel" output-channel="loggerChannel">
(3)  <int:service-activator ref="exchangeMessageServiceActivator" />
(4)  <int:claim-check-in/>
(5)  <int:claim-check-out/>
(6)  <int:transformer expression="payload.getRequest()" />
(7)  <ws:outbound-gateway uri="http://.../>
(8)  <int:transformer ref="xmlMsgToPojoTransformer" />

    ... processing ...

</int:chain>

Basically, in (1) and (2) I send a simple POJO to the inbound Gateway, and it is transformed into a simple SOAP Request (a String).

Within the chain, in (3), the exchangeMessageServiceActivator bean accepts the String, and creates an ExchangeMessage Object, calling its setRequest() method with the SOAP Request.

In (4) I save the newly created ExchangeMessage in the Claim Check.

In (5), I check it back out and in (6) and (7) send the contents of ExchangeMessage.getRequest() to the WS Outbound Gateway. I realize I could have done this using a Header Enricher, but since I want to save the ExchangeMessage Object anyway, I figured it's pretty much the same thing, even though calling claim-check-out immediately after claim-check-in is kind of ugly.

The problem begins between (7) and (8). The payload of (7) is the SOAP Response. Before unmarshalling it into an Object (and then processing it ...), I want to retrieve the ExchangeMessage using < claim-check-out >, call the ExchangeMessage.setResponse() method with the SOAP Response, and then convert the SOAP Response to an Object for processing.

The problem is, if between (7) and (8) I stick a < claim-check-out >, I lose the original payload of (7), the SOAP Response.

I've thought about using some kind of Service Activator between (7) and (8), to somehow load the ExchangeMessage from the Claim Check, and call its setResponse() method using the payload from (7), but I can't figure out how to do it. I've gotten this far:

SimpleMessageStore simpleMessageStore = (SimpleMessageStore)context.getBean("simpleMessageStore");
ClaimCheckOutTransformer claimCheckOutTransformer = new ClaimCheckOutTransformer(simpleMessageStore);
claimCheckOutTransformer.transform(Message???);

If the payload for this Service Activator will be a String (the SOAP Response) where does the Message come from that I need to pass to how to ClaimCheckOutTransformer.transform()?

I love Spring Integration. But this one's got me stumped.

1

1 Answers

0
votes

It would be simpler to save off your ExchangeMessage in a header using a header-enricher, instead of using a claim check.

That way, it's available to you later in the flow to call setResponse().

Otherwise, you'd need to save off the claimcheck payload (between 4 and 5) and also the response before checking out again - but that would be a more complex flow than simply saving off the original object and not using a claim check at all.