我想使用ahc组件调用外部http服务,将camel-ahc依赖项添加到pom.xml中,并且还在karaf中安装了camel-ahc功能:
feature:install camel-ahc
已添加的捆绑包:
camel-ahc和wrap_file__home_ossl_.m2_repository_org_asynchttpclient_async-http-client_2.4.3_async-http-cl ...
我的代码是:
<camelContext id="jetty-ws-camel-ahc" xmlns="http://camel.apache.org/schema/blueprint" >
<route id="ahc-route">
<from uri="timer://webinar?period=20000"/>
<setHeader headerName="CamelHttpMethod">
<constant>GET</constant>
</setHeader>
<to uri="ahc:http://217.0.0.0:3030/sendSMS/mynumber/bye"/>
<log message="message sent!"/>
</route>
</camelContext>
但是我有一个警告并且请求没有发送到http地址:WARN [Blueprint Extender:3]监听器导致异常,将忽略java.util.concurrent.ExecutionException:java.lang.NoClassDefFoundError:org / reactivestreams / Publisher
引起:java.lang.ClassNotFoundException:org.reactivestreams.Publisher找不到wrap_file__home_ossl_.m2_repository_org_asynchttpclient_async-http-client_2.4.3_async-http-client-2.4.3.jar_Export-Package_org.asynchttpclient .__ version_2.4.3
我该怎么办?
问题是神器org.asynchttpclient/async-http-client
的自动包装。
默认情况下,包装会使所有Import-Package子句成为可选项,这有时会使构建可靠的有线设置变得困难,因为当解析器在查看导出“可选”包的包之前查看包装的包时,它们将不会连接在一起并且由于它们是可选的,即使稍后出现一微秒,解析器也会很乐意跳过它们。
要测试这个,你可以bundle:refresh <id>
async-http-client捆绑包,看看bundle:tree-show <id>
是否仍然没有连接包(标记为WARNING
)。
为了可靠地修复它,您可以根据官方的Apache Camel功能创建自己的功能,并修改包装以强制执行某些导入(例如,将&Import-Package=org.reactivestreams,*;resolution:=optional
附加到wrap:
语句中)。
还看看Wrap Protocol。