我試圖實現,搜索外部數據庫的項目的服務,如有發現,將其保存在當地的一個。Apache的駱駝:錯誤時Bean端點返回null
我有以下途徑:
from("direct:find-and-save")
.to("bean:itemSearcher?method=searchFor(${header.brand}, ${header.model})")
.to("bean:itemConverter")
.to("bean:itemRepository?method=saveItem");
它完美的時候itemSearcher
發現的項目。當itemSearcher
找不到該項目時,它將返回null
。我預期消息的該機構將被設置爲null
但我得到以下異常:之後itemSearcher
回報null
和看到null
有效地得到了設置的OUT-體
org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.camel.converter.stream.InputStreamCache to the required type
我已經調試駱駝的代碼當前交換的消息,然後出口消息成爲下一個交換的消息。但是無論如何,某處的身體都會被InputStreamCache
取代。
我的問題是:我怎麼可以配置駱駝保護null
值作爲消息的身體嗎?如果這是不可能的,我該如何解決讓bean不應該擁有Camel的依賴關係(即不能以Exchange
實例爲參數)。
請點我,如果我失去了在文檔中的東西我讀過:
我用駱駝v 2.18.0
。
我真的懷疑Camel默認添加InputStreamCache,因爲我有在流程的各個步驟中返回null的路由,我使用choice()/ when()來確定正文的內容。你可能想在itemConverter之後添加一個條件來檢查一個空體。以及你的物品轉換器bean中的代碼是怎樣的? –