在Camel上使用Springboot的Rest DSL在重新启动EAP引发异常后创建路由

时间:2018-10-15 13:28:42

标签: java rest apache-camel jbossfuse jboss-eap-6

当我尝试通过以下链接在springboot项目中进行dsl休息时:

https://developers.redhat.com/blog/2018/03/26/camel-spring-boot-rest-dsl/

我的源代码的总体框架如下:

        rest("http://localhost:8080/camel-services/rest/Test1")
        .post()
        .to("direct:route1");

         from("direct:route1")
        .to("mock:route");

使用的springboot版本是: 1.5.1.RELEASE ,我正在尝试使用 fuse-eap在 EAP-6.4.0 中部署WAR文件。 -installer-6.2.1.redhat-169.jar 安装在EAP上。

当我第一次部署应用程序时,它可以工作,但是当我取消部署并重新启动EAP并再次部署它失败时,它会为发布请求创建一个ID,因此下次应用程序启动失败时会出现以下异常:

Caused by: org.apache.camel.FailedToStartRouteException: Failed to start route post1 because of duplicate id detected: post1. Please correct ids to be unique among all your routes.
        at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1134) [camel-core-2.21.1.jar:2.21.1]
        at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3731) [camel-core-2.21.1.jar:2.21.1]
        at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3445) [camel-core-2.21.1.jar:2.21.1]
        at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:209) [camel-core-2.21.1.jar:2.21.1]
        at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3253) [camel-core-2.21.1.jar:2.21.1]
        at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3249) [camel-core-2.21.1.jar:2.21.1]
        at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3272) [camel-core-2.21.1.jar:2.21.1]
        at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3249) [camel-core-2.21.1.jar:2.21.1]
        at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) [camel-core-2.21.1.jar:2.21.1]
        at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3165) [camel-core-2.21.1.jar:2.21.1]
        at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:133) [camel-spring-2.21.1.jar:2.21.1]
        ... 28 more

1 个答案:

答案 0 :(得分:1)

您不应在EAP / JBoss WildFly之类的其他应用服务器中运行Spring Boot。

您收到的错误闻起来像是取消部署过程并未完全取消部署所有资源。我知道最近修复了野蝇骆驼中的一个错误,但这与使用camel-cxf和热部署有关。

因此,我的第一个建议是不要在EAP内使用Spring Boot,而仅在EAP上使用标准JEE。请参阅widlfly-camel文档和示例:https://github.com/wildfly-extras/wildfly-camel