0

我正在为 http 服务器使用 apache camel http4。JBoss Fuse Karaf 容器 6.3.0.redhat-310 已捆绑 camel-core 2.17 - (2.17.0.redhat-630310)

我正在尝试使用异常类 org.apache.camel.component.http.HttpOperationFailedException 来捕获 HTTP 响应异常。

但是,由于 Caused by: java.lang.ClassNotFoundException: org.apache.camel.component.http.HttpOperationFailedException 导致关联路由无法启动

我添加为依赖camel-http,没有任何变化,仍然失败。

似乎不再包括这个类了?

Q. 是由以下原因引起的:java.lang.ClassNotFoundException: org.apache.camel.component.http.HttpOperationFailedException 可用于 http4 服务器,或者有谁知道我做错了什么。

    <when id="w2">
        <ognl>request.headers.TKNDB == true</ognl>
        <process id="a3" ref="assetUploadProcessor"/>
        <setHeader headerName="CamelHttpUri" id="h1">
            <simple>${header.UPLOADURL}</simple>
        </setHeader>
        <setHeader headerName="CamelHttpMethod" id="h2">
            <constant>GET</constant>
        </setHeader>
        <doTry id="_doTry1">
            <to id="http4-1" uri="http4://d1e53858-2903-4c21-86c0-95edc7a5cef2.predix-uaa.run.aws-usw02-pr.ice.predix.io:443/oauth/token?throwExceptionOnFailure=false"/>
            <doCatch id="_doCatch1">
                <exception>org.apache.camel.component.http.HttpOperationFailedException</exception>
                <onWhen>
                <simple>${header.HTTP_RESPONSE_CODE} range "400..600"</simple>
                </onWhen>
                <log id="_log2" loggingLevel="ERROR" message="HTTP FAILURE - HTTP Response Code: ${header.HTTP_RESPONSE_CODE}"/>
            </doCatch>
        </doTry>
        <log id="l1" loggingLevel="INFO" message="JSON Response: ${body}"/>
        <process id="jsonmapperassets" ref="jsonMapperAssets"/>
        <split id="as1"

YEILDS ...因为 org.apache.camel.component.http.HttpOperationFailedException 引起:java.lang.ClassNotFoundException:org.apache.camel.component.http.HttpOperationFailedException

我也尝试过使用全局异常处理程序

<exception>org.apache.camel.component.http.HttpOperationFailedException</exception>
      <continued>true</continued>
    </onException>

但是,在这里我得到一个错误异常说继续不能有孩子????

谢谢你!

4

2 回答 2

1

我遇到了同样的问题,正确的课程是

org.apache.camel.http.common.HttpOperationFailedException

它应该在 http4 组件内

于 2020-10-16T11:26:29.027 回答
0

我只是使用简单的语言来实现我所需要的。我只需要在 http 错误代码不正常或 200 之后继续路由。这种方法有效,但我很想了解如何用我的原始问题来完成此操作。

这可以用骆驼的http4组件来完成吗,看来这些类不再是它的一部分了?

另外,如果有人可以,我的 onException 子句有什么问题?

谢谢!

这就是我所做的

<to id="http4-1" uri="http4://d1e53858-2903-4c21-86c0-95edc7a5cef2.predix-uaa.run.aws-usw02-pr.ice.predix.io:443/oauth/token?throwExceptionOnFailure=false"/>
<choice>
 <when>
  <simple>${header.CamelHttpResponseCode} == '200'</simple>
    <log id="l1" loggingLevel="INFO" message="JSON Response Body: ${body}"/>
    <process id="jsonmapperassets" ref="jsonMapperAssets"/>
  <split id="as1"
    strategyRef="tsAggregationStrategy" streaming="true">
    <simple>${body}</simple>
    <log id="al6" loggingLevel="INFO" message="Split line ${body}"/>
    <process id="p1" ref="getAssets"/>
  </split>
  <process id="getassetlisting" ref="getAssetListing"/>
  <split id="as2"
    strategyRef="tsAggregationStrategy" streaming="true">
    <simple>${body}</simple>
    <log id="sl2" loggingLevel="INFO" message="Split assets ${body}"/>
    <process id="gtags" ref="setTagURL"/>
    <to id="surl" ref="setURL"/>
  </split>
 </when>
 <otherwise>
   <log id="logError1" loggingLevel="ERROR" message="HTTP FAILURE - Response Code: ${header.CamelHttpResponseCode}"/>
   <log id="logError2" loggingLevel="ERROR" message="HTTP FAILURE - Response: ${header.CamelHttpResponseText}"/>
 </otherwise>
</choice>
于 2019-09-11T22:35:47.333 回答