如何在Camel中处理多个CXF端点



我有两个端点:

<cxf:cxfEndpoint address="http://localhost:9090/fileTransferService" id="FileTransferServiceEndpoint" serviceClass="FileTransferService">
<cxf:properties>
<entry key="dataFormat" value="POJO"/>
<entry key="loggingFeatureEnabled" value="true"/>
</cxf:properties>
</cxf:cxfEndpoint>
<cxf:cxfEndpoint address="http://localhost:9090/cardPaymentService" id="PaymentServiceServiceEndpoint" serviceClass="CardPayment">
<cxf:properties>
<entry key="dataFormat" value="POJO"/>
<entry key="loggingFeatureEnabled" value="true"/>
</cxf:properties>
</cxf:cxfEndpoint>
  • 文件传输服务的路由

    <from id="from1" uri="cxf:bean:FileTransferServiceEndpoint"/>
    ...
    
  • 卡支付服务的路线

    <from id="from2" uri="cxf:bean:PaymentServiceServiceEndpoint"/>
    ...
    

每个端点都用于来自某个客户端的每个路由。当我的间谍应用程序加载路由时,我找不到cardPaymentService的web服务。但是我可以找到fileTransferServices的web服务。

我想提供多种网络服务。如何配置我的路线?

谢谢。

我使用的是camel版本2.23.2。

加载路由后,我只找到了一个web服务。当我重新加载应用程序时,我发现以下异常。

[2019-11-11 23:31:21.644][Thread-30 (182)][INFO ][o.e.j.s.h.ContextHandler] Stopped o.e.j.s.h.ContextHandler@aadbe9e{/,null,UNAVAILABLE}
[2019-11-11 23:31:21.644][Thread-30 (182)][INFO ][o.e.j.s.h.ContextHandler] Stopped o.e.j.s.h.ContextHandler@1cf96cd{/,null,UNAVAILABLE}
[2019-11-11 23:31:21.651][Thread-30 (182)][INFO ][o.e.j.s.AbstractConnector] Stopped ServerConnector@34ff8753{HTTP/1.1,[http/1.1]}{localhost:9090}
java.lang.NullPointerException
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine.stop(JettyHTTPServerEngine.java:1040)
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory.destroyForPort(JettyHTTPServerEngineFactory.java:318)
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine.shutdown(JettyHTTPServerEngine.java:210)
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory.postShutdown(JettyHTTPServerEngineFactory.java:372)
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory$JettyBusLifeCycleListener.postShutdown(JettyHTTPServerEngineFactory.java:155)
at org.apache.cxf.bus.managers.CXFBusLifeCycleManager.postShutdown(CXFBusLifeCycleManager.java:110)
at org.apache.cxf.bus.extension.ExtensionManagerBus.shutdown(ExtensionManagerBus.java:306)
at org.apache.cxf.bus.extension.ExtensionManagerBus.shutdown(ExtensionManagerBus.java:282)
at org.apache.cxf.bus.spring.SpringBus.onApplicationEvent(SpringBus.java:109)
at org.apache.cxf.bus.spring.SpringBus$1.onApplicationEvent(SpringBus.java:58)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:975)
at target.atom.engine.TargetAtomEngineApplication.lambda$0(TargetAtomEngineApplication.java:100)
at java.base/java.lang.Thread.run(Thread.java:834)

以下是加载应用程序期间的日志。

[2019-11-11 23:31:26.849][Thread-30 (182)][INFO ][o.a.c.w.s.f.ReflectionServiceFactoryBean] Creating Service {http://transfer.file.ws.van.processor.targetline/}FileTransferService from class targetline.processor.van.ws.file.transfer.FileTransferService
[2019-11-11 23:31:26.901][Thread-30 (182)][INFO ][o.a.c.e.ServerImpl] Setting the server's publish address to be http://localhost:9090/fileTransferService
[2019-11-11 23:31:26.922][Thread-30 (182)][INFO ][o.a.c.w.s.f.ReflectionServiceFactoryBean] Creating Service {http://payment.ws.van.processor.targetline/}CardPayment from class targetline.processor.van.ws.payment.CardPayment
[2019-11-11 23:31:26.992][Thread-30 (182)][INFO ][o.a.c.e.ServerImpl] Setting the server's publish address to be http://localhost:9090/cardPaymentService
[2019-11-11 23:31:27.011][Thread-30 (182)][INFO ][o.e.j.s.Server] jetty-9.4.19.v20190610; built: 2019-06-10T16:30:51.723Z; git: afcf563148970e98786327af5e07c261fda175d3; jvm 11.0.2+9
[2019-11-11 23:31:27.017][Thread-30 (182)][INFO ][o.e.j.s.AbstractConnector] Started ServerConnector@4d6e2c22{HTTP/1.1,[http/1.1]}{localhost:9090}
[2019-11-11 23:31:27.017][Thread-30 (182)][INFO ][o.e.j.s.Server] Started @383149ms
[2019-11-11 23:31:27.017][Thread-30 (182)][WARN ][o.e.j.s.h.ContextHandler] Empty contextPath

重启功能

public static void restart() {
ApplicationArguments args = context.getBean(ApplicationArguments.class);
Thread thread = new Thread(() -> {
context.close();
context = SpringApplication.run(TargetAtomEngineApplication.class, args.getSourceArgs());
});
thread.setDaemon(false);
thread.start();   
}

我认为您必须使用两个不同的端口(例如9090和9091(-每个服务一个。

相关内容

  • 没有找到相关文章

最新更新