[英]Spring Integration 3.0.1 Restful http-inbound-gateway doesn't convert request body into object
[英]Spring Integration HTTP Inbound Gateway Request Overlap
我的集成應用程序中有一個HTTP入站網關,在某些保存操作期間將調用它。 就像這樣。 如果我有一個產品,我將調用一次API,如果我有多個產品,則將調用多次。 問題是,對於單次調用,SI可以正常工作。 但是對於多個呼叫,請求和響應變得混亂。 我以為Spring Integration Channels就像MQ一樣,但是不是嗎?
讓我解釋一下。 假設我有2種產品。 首先,我先對產品A調用SI,然后對產品B調用。A的響應已映射到請求B! 它一直在發生。 我不想使用一些骯臟的技巧,例如等待第一個響應出現並再次調用。 這意味着系統必須等待很長時間。 我想我們可以使用任務執行程序在Spring Integration中做到這一點,但由於那里有所有基本示例,所以我找不到合適的示例。 因此,請幫助我找出如何解決此問題!
我的配置是:
<int:channel id="n2iMotorCNInvokeRequest" />
<int:channel id="n2iMotorCNInvokeResponse" />
<int:channel id="n2iInvoketransformerOut" />
<int:channel id="n2iInvokeobjTransformerOut" />
<int:channel id="n2iInvokegatewayOut" />
<int-http:inbound-gateway id="i2nInvokeFromPOS"
supported-methods="GET"
request-channel="i2nInvokeRequest"
reply-channel="i2nInvokeResponse"
path="/postProduct/{Id}"
mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS"
reply-timeout="50000">
<int-http:header name="Id" expression="#pathVariables.Id"/>
</int-http:inbound-gateway>
<int:service-activator id="InvokeActivator"
input-channel="i2nInvokeRequest"
output-channel="i2nInvokeResponse"
ref="apiService"
method="getProductId"
requires-reply="true"
send-timeout="60000"/>
<int:transformer input-channel="i2nInvokeResponse"
ref="apiTransformer"
method="retrieveProductJson"
output-channel="n2iInvokeRequest"/>
<int-http:outbound-gateway request-channel="n2iInvokeRequest" reply-channel="n2iInvoketransformerOut"
url="http://10.xx.xx.xx/api/index.php" http-method="POST"
expected-response-type="java.lang.String">
</int-http:outbound-gateway>
<int:service-activator
input-channel="n2iInvoketransformerOut"
output-channel="n2iInvokeobjTransformerOut"
ref="apiService"
method="productResponse"
requires-reply="true"
send-timeout="60000"/>
i2nInvokeFromPOS網關是我們從Web應用程序調用的位置,它將在其中創建所有產品。 該Integration API將獲取該數據,並將其發布到后端系統,以便也將其更新到其他POS位置!
腳步 :
我將productId發送到i2nInvokeFromPOS。
apiTransformer-> RetrieveProductJson()方法將根據ID從數據庫中獲取產品詳細信息
使用http:outbound-gateway將請求JSON發送到后端系統
從后端獲取響應,並更新數據庫中上傳的產品狀態。 發生在apiService-> productResponse()中
收到A的響應后,我得到的只是請求B的HTTP 500錯誤! 但是后端API很好。
該框架是完全線程安全的-如果您看到不同的請求/響應之間存在串擾,則該框架正在調用的一個(或多個)組件不是線程安全的。
您不能在例如從服務激活器調用的代碼中的字段中保持狀態。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.