Spring Integration - How to save the original payload and use it later?

I would like to keep the original payload of the original queries and fix it in the xslt transformer or in another operation. I lose it because I use xslt-transformer and I only need some of the elements in the conversion. Therefore my script:

1.inbound-gateway (incoming WS req) β†’ 2.xslt-transformer (mapping for calling an external WS) β†’ 3.outbound-gateway (calling for an external WS) β†’ 4.xslt-transformer (creating a response from the external WS and the original request)

In step 4, I do not have the original req, but I would need it, since I needed to put the values ​​from it in the answer. How can I implement it?

Thank you in.

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-ws="http://www.springframework.org/schema/integration/ws" xmlns:int-xml="http://www.springframework.org/schema/integration/xml" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/integration/ws http://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration/xml http://www.springframework.org/schema/integration/xml/spring-integration-xml.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> <bean id="authenticator" class="uk.co.virginmedia.test.Authenticator"/> <bean id="webserviceDestinationProvider" class="uk.co.virginmedia.test.WebserviceDestinationProvider"/> <bean id="resultToDocumentTransformer" class="org.springframework.integration.xml.transformer.ResultToDocumentTransformer"/> <util:map id="orderNamespaceMap"> <entry key="res" value="http://schema/ReserveAppointment/2/0" /> </util:map> <int-ws:inbound-gateway id="ws-gateway-for-rbta" request-channel="incoming-req-channel" reply-channel=""/> <int:channel id="incoming-req-channel"/> <int:service-activator id="authentication" input-channel="incoming-req-channel" ref="authenticator" method="authenticate" output-channel="authenticated-channel" /> <int:channel id="authenticated-channel"/> <int-xml:xpath-router id="servicetype-router" input-channel="authenticated-channel" evaluate-as-string="true"> <int-xml:xpath-expression expression="//res:ReserveAppointmentRequest/res:serviceType/text()" ns-prefix="res" ns-uri="http://schema/ReserveAppointment/2/0"/> <int-xml:mapping value="Broadband" channel="broadband-channel"/> <int-xml:mapping value="FTTC+WholesaleLineRental" channel="fttc-wlr-channel"/> </int-xml:xpath-router> <int:channel id="broadband-channel"/> <int-xml:xslt-transformer id="req_for_bt_xslt_transformer" input-channel="broadband-channel" output-channel="domresult_for_bt_channel" xsl-resource="classpath:/xsl/ToBTReq.xsl" result-type="StringResult"/> <int:channel id="domresult_for_bt_channel"/> <int:transformer input-channel="domresult_for_bt_channel" output-channel="document_for_bt_channel" expression="payload.toString()"/> <int:channel id="document_for_bt_channel"/> <int-ws:outbound-gateway request-channel="document_for_bt_channel" reply-channel="resp_from_bt_channel" destination-provider="webserviceDestinationProvider" id="call_bt-outbound_gateway" /> <int:channel id="resp_from_bt_channel"/> <int-xml:xslt-transformer id="resp_for_rbta_xslt_transformer" input-channel="resp_from_bt_channel" output-channel="resp_for_rbta_channel" xsl-resource="classpath:/xsl/ToBTReq.xsl" result-type="StringResult"/> 

+6
source share
1 answer

Since your original message is just text, you can copy it into the header field. This should work as long as you do nothing special between when you store and then retrieve it.

So I would try:

 <int:header-enricher input-channel="authenticated-channel" output-channel="pre-routing-channel"> <int:header name="original-payload" expression="payload.toString()" /> </int:header-enricher> <!-- changed input channel of router --> <int-xml:xpath-router id="servicetype-router" input-channel="pre-routing-channel" evaluate-as-string="true"> 

If this does not work for you (perhaps because you need to do something more special between or the payload is too high), you still have the option to use ClaimCheck . In fact, this is exactly what you are asking for. To do this, you will need a MessageStore , and then just save the message payload before modifying it. Therefore, instead of the enrichment header, you call

 <int:claim-check-in input-channel="authenticated-channel" output-channel="pre-routing-channel" message-store="payloadstore" /> <!-- MessageStore definition storing payload using in memory map --> <bean id="simpleMessageStore" class="org.springframework.integration.store.SimpleMessageStore"/> 
+4
source

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


All Articles