![](/img/trans.png)
[英]Spring Integration with AMQP: get original message's custom-headers on error-channel
[英]Spring integration Error handling - How do I access original faulty message's history?
我們有一個 spring-integration 應用程序,我們想在其中處理錯誤通道上的消息。至少我們想提取歷史記錄並記錄它,以便我們可以看到它究竟在哪里失敗等
這是這一點的簡短標記
<int:poller id="defaultPoller" default="true" fixed-delay="5000" />
<int:channel id="MyCustomErrorChannel">
<int:queue capacity="10"/>
</int:channel>
<int:header-enricher id="errorMsg.HeaderEnricher"
input-channel="errorChannel"
output-channel="MyCustomErrorChannel">
<int:header name="history" expression="payload.failedMessage.headers" />
</int:header-enricher>
<int:service-activator input-channel="MyCustomErrorChannel" ref="errorLogger" method="logError"/>
<bean id="errorLogger" class="com.dataprep.util.ErrorLogger" />
這個想法是定義我們的自定義錯誤通道MyCustomErrorChannel 。 任何在默認 errorChannel 中結束的錯誤在被放到MyCustomErrorChannel之前都會得到它的標題的豐富最后我們有一個記錄器從MyCustomErrorChannel讀取消息並記錄有效負載,它是基礎異常和歷史記錄。
我注意到我的記錄器中的歷史記錄總是 3 個步驟 errorChannel,errorMsg.HeaderEnricher,pbSwiftRouterErrorChannel即在此消息登陸 errorChannel 之前,歷史記錄中沒有任何內容。 如何獲取原始消息的歷史記錄(即以某種方式作為新錯誤消息登陸默認錯誤通道的錯誤消息的歷史記錄)
你能看看我的標題豐富器,讓我知道如何訪問失敗消息的標題並將其填充到錯誤消息中嗎?
它完全可行嗎?
要替換現有標題,您應該使用overwrite="true"
,因為history
也是為ErrorChannel
構建的。
您應該使用history
headers
完全覆蓋,而不是整個headers
。 因此你的表達必須是這樣的:
<int:header name="history" expression="payload.failedMessage.headers.history" overwrite="true"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.