Apache 的 http4 可以使用 HttpOperationFailedException 吗?

Is HttpOperationFailedException available with apache's http4?

我正在为 http 服务器使用 apache camel http4。 JBoss 保险丝 Karaf 容器 6.3.0.redhat-310 已捆绑骆驼核心 2.17 - (2.17.0.redhat-630310)

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

但是,由于以下原因,关联的路由无法启动 原因:java.lang.ClassNotFoundException:org.apache.camel.component.http.HttpOperationFailedException

我添加了依赖camel-http,没有改变,仍然失败。

这个class好像不收录了?

问。是否由以下原因引起: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"

产量 ... 因为 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>

但是,在这里我得到一个错误异常,说 Continued cannot have children?????

谢谢!

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

这可以用 camel 的 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>

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

org.apache.camel.http.common.HttpOperationFailedException

它应该在 http4 组件中