1
我是新的春季整合,我的要求是我會得到一個http請求到我的春天集成,然後我需要按照以下步驟。春季整合http入站網關協議問題
1)得到的HTTP請求 2)發送給第三方(MQ) 3)將收到從MQ 4的響應)處理消息併發送回客戶端。
我做了這個applciation和工作正常,但是當我如果同時得到多個請求,我面臨的問題一樣,而發送請求到Thridaprty我構造一些UUID和correlID在我的頭並保持在我的本地緩存,所以如果同時有多個請求,我的代碼會創建相同的correlID。
我懷疑同一毫秒有多個請求的問題。
請親切指導我出了什麼問題。
這是我的配置工作正常單個請求。
<int-http:inbound-gateway id="requestGateway"
supported-methods="GET"
request-channel="requestChannel"
reply-channel="replyChannel"
path="${cuteRequestURL}"
reply-timeout="${cuteRequestTimeout}"
>
</int-http:inbound-gateway>
<int:channel id="requestChannel"/>
<bean id="mapToSI" class="aero.sita.fw.cutelvihttp.helper.TransformLinkedMultiValueMapToSIMsg"/>
<int:transformer id="abc"
input-channel="requestChannel"
output-channel="Map"
ref="mapToSI"
method="transformLinkeMapToSpringIntegrationMessage" />
<int:channel id="Map"/>
<bean id="constructRequiredParams" class="SomeParamLogic">
<constructor-arg name="Value1" value="A" />
<constructor-arg name="Value2" value="B" />
<constructor-arg name="Value3" value="C" />
</bean>
<int:transformer id="constructMessageHeaderVendor"
input-channel="Map"
output-channel="inputRequestChannel"
ref="constructRequiredParams"
method="amend" />
<int:channel id="inputRequestChannel" />
<int:service-activator input-channel="inputRequestChannel"
output-channel="responseValidatorChannel"
method="xyz"
ref="serviceActivator"/>
<int:channel id="responseValidatorChannel"/>
<bean id="serviceActivator" class="ServiceActivator"/>
<int:channel id="replyChannel"/>
<int:channel id="dataChannel" />
<int:service-activator input-channel="dataChannel"
ref="destinationQueue"
method="transform"/>
<bean id="destinationQueue" class="XYZ">
<property name="requestQueue" value="ProducerName" />
<property name="replyQueue" value="Replier" />
</bean>
<int-xml:validating-filter discard-channel="errorChannel"
id="jmsInValidator"
input-channel="dataChannel"
output-channel="nullChannel"
schema-location="ThirdParty.xsd"
schema-type="xml-schema"
throw-exception-on-rejection="true" />
<int-xml:validating-filter discard-channel="errorChannel"
id="jmsInValidator"
input-channel="responseValidatorChannel"
output-channel="replyChannel"
schema-location="classpath:Client.xsd"
schema-type="xml-schema"
throw-exception-on-rejection="true" />
不確定爲什麼顯示集成配置,您確認自己的代碼中的競爭條件生成了uuid和相關性。我認爲你應該展示一個。甚至更好的是,編寫一些測試用例來檢測競爭情況。 Otoh你應該考慮使用現有的uuid算法來避免衝突。同時也有'閂鎖'障礙來保護資源免受併發訪問。任何方式的問題看起來都遠離Spring Integration –
謝謝Artem Bilan的回覆。 – user3749024
謝謝Artem Bilan的回覆。我重新構建了我的問題,Spring集成是線程安全的嗎?我使用服務激活器來偵聽第三方響應(請求/回覆),一旦我得到響應發送回HTTP客戶端。 HTTP - >我的應用程序是synchronus和我的應用程序 - > MQ Applicaiotn是Aysnchrouns,所以服務激活器將在這裏維護線程安全,這就是我想問的,善意地確認,按照你的建議我改變了創建UUID的工作正常問題解決了,現在我想知道關於線程安全 – user3749024