cxf - Servicemix 7.0.1 - 迁移后 cxf 服务器启动太慢
问题描述
在从 ServiceMix 5.1.4 (smx-5) 迁移到 ServiceMix 7.0.1 (最新稳定版本) (smx-7) 的上下文中,我可以使用 cxf:RsServer 在我的骆驼路线上看到一个奇怪的行为
我的骆驼路线如下所示:
from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer&synchronous=true")
.setBody(simple("${body[0]}"))
.marshal(df)
.convertBodyTo(String.class)
.to("{{user.request.endpoint}}")
.process(checkResponseStatusCode())
.unmarshal(df);
在蓝图中我有:
<cxf:rsServer id="rsServer" address="/user-data/v1"
loggingFeatureEnabled="true" depends-on="user-rest-v1"
serviceClass="org.my.company.user.rest.v1.resources.UserDataServiceRest"
staticSubresourceResolution="true">
<cxf:providers>
<bean name="jacksonJsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
<ref component-id="authenticationFilter" />
</cxf:providers>
<cxf:properties>
<entry key="binding">
<ref component-id="mySecurityCxfRsBinding" />
</entry>
</cxf:properties>
</cxf:rsServer>
UserDataServiceRest 类包含方法签名并按照旧null
骆驼规范返回。我知道它现在支持接口,但我不确定这可能是我的问题的原因。
我是 smx-5 版本,所有包都在几秒钟内启动(每个包)。在 smx-7 中,相同的捆绑包至少会在 2 分钟内启动(每个捆绑包)。
虽然需要很长时间,但我在日志中看不到任何活动。
请注意,我也有这样的服务器问题:
<jaxrs:server id="pingServiceSvc" address="/ping">
<jaxrs:serviceBeans>
<ref component-id="pingServiceBean" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref component-id="commonExceptionHandler" />
</jaxrs:providers>
<jaxrs:inInterceptors>
<ref component-id="requiredParametersInterceptorBean" />
</jaxrs:inInterceptors>
</jaxrs:server>
这对于任何请求(ping 服务)都可以回答。
我的设置:
- 服务混合 7.0.1 ()
- 没有嵌入式 ActiveMQ
- 安装在 RedHat 7 linux 上
- Java JDK 8 (openJDK build 1.8.0_212-b04)
更新
当我在本地尝试(CentOS 6.10)时,捆绑包(暴露 CXF 服务器)在大约 20 秒内启动。但是当它部署在真实服务器(RHEL 7)上时,它需要超过 2 分钟。我怀疑是网络问题,但日志中没有任何内容。配置几乎相同......我正在研究它。
解决方案
我找到了解决方案。
促使我找到解决方案的是我的日志中的这些警告消息:
2019-06-27T09:24:24Z | WARN | NamespaceHandlerRegistryImpl | 34 | NamespaceHandler org.apache.camel.blueprint.handler.CamelNamespaceHandler is behaving badly and should be fixed | | |
2019-06-27T09:24:24Z | WARN | NamespaceHandlerRegistryImpl | 34 | NamespaceHandler org.apache.camel.component.cxf.blueprint.CxfNamespaceHandler is behaving badly and should be fixed | | |
2019-06-27T09:24:24Z | DEBUG | BlueprintContainerImpl | 34 | Running blueprint container for bundle com.mycompany.user.user-rest-v1/1.0.1.SNAPSHOT in state WaitForNamespaceHandlers | | |
2019-06-27T09:24:24Z | WARN | NamespaceHandlerRegistryImpl | 34 | Unable to find namespace handler for http://cxf.apache.org/configuration/beans | | |
CXF 中的命名空间处理程序似乎存在问题,并且可能由于我的服务器无法访问 Internet,因此出现超时。
在这一点上,这些只是猜测。
在互联网上搜索了一些关于这个主题的信息后,我发现这个 jira似乎在更高版本的 Camel 中有修复(根据 JIRA 票证,从 2.18 和 2.19 开始)。
不幸的是,没有比 2.16.5 更新的 Camel 版本更稳定的 ServiceMix 版本。
然后我尝试使用更新的 Camel 版本升级我的 ServiceMix 7.0.1:2.23.0(我也尝试使用 2.24.1,但我的许多 OSGI 依赖项都被破坏了。)
我应用的更改是:
在文件中
org.apache.karaf.features.cfg
更改了行:mvn:org.apache.camel.karaf/apache-camel/2.16.5/xml/features, \
与:mvn:org.apache.camel.karaf/apache-camel/2.23.0/xml/features, \
在文件中
profile.cfg.erb
更改了行:repository.mvn\:org.apache.camel.karaf/apache-camel/2.16.5/xml/features = mvn:org.apache.camel.karaf/apache-camel/2.16.5/xml/features
与:repository.mvn\:org.apache.camel.karaf/apache-camel/2.23.0/xml/features = mvn:org.apache.camel.karaf/apache-camel/2.23.0/xml/features
之后, * 停止你的 ServiceMix * 清理缓存文件夹 * 启动 ServiceMix
clean
(或使用选项重新启动 servicemix )
完全启动后,当我重新安装我的功能时,所有捆绑软件都以比以前更快的方式顺利启动。
结论:SM-3390 可能是捆绑包启动缓慢的原因。
推荐阅读
- javascript - 从字符串中删除字符会删除某些字母的倍数,但不会删除其他字母
- ios - iPad 上 NavigationLink 的奇怪行为
- svg - svg 鼠标悬停位置的工具提示
- python - 根据下一行列创建列
- hive - 在 Hive2 中向 ORC 表中插入数据
- javascript - 映射文本和 html。职位搜索
- php - 带变量的 PHP SQL Where
- javascript - JavaScript 未能执行“transferControlToOffscreen”
- python - 从 csv.Sniffer() 中排除分隔符
- javascript - 如何使用谷歌应用脚本将 zip/rar 文件上传到谷歌驱动器?