我有一個錯誤處理的路線:Apache Camel:我如何從Rest API返回消息?
<route errorHandlerRef="magentoCustomerErrorHandler" id="customers.route2">
...
<to id="_to1" uri="http4://{{magento.api.url}}customer/"/>
</route>
而在我的錯誤處理程序,我稱之爲處理器onRedelivery
<bean class="br.com.company.ProcessorError" id="myErrorProcessor"/>
<bean class="org.apache.camel.builder.DeadLetterChannelBuilder" id="magentoCustomerErrorHandler">
<property name="deadLetterUri" value="activemq:magento:customers:DQL"/>
<property name="onRedelivery" ref="myErrorProcessor"/>
<property name="redeliveryPolicy" ref="myRedeliveryPolicyConfig"/>
</bean>
在錯誤處理,我試圖讓該消息被返回該API,但我只收到駱駝生成的消息。
ErrorProcessor類:
public void process(Exchange exchange) throws Exception {
Exception cause = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
exchange.getIn().setHeader("FailedBecause", cause.getMessage());
}
API響應:
{"messages":{"error":[{"code":500,"message":"Token doesn't exist or is expired."}]}}
預期消息:
Token doesn't exist or is expired
返回消息:
HTTP operation failed invoking http://myurl.com/api/rest/customer/ with statusCode: 500
這是行不通的。我想獲得請求正文。對我來說,使用原始消息,不要改變任何東西。 –