org.apache.camel.ResolveEndpointFailedException:由于以下原因导致无法解析端点:org.apache.camel.Header缺少元素值

时间:2019-06-03 10:19:48

标签: java spring apache apache-camel activemq

作为升级Spring Jar的一部分,我们将Spring依赖项从2.5升级到4.3.0版本。 还将apache骆驼罐从1.6.0版本更新到了2.6.0(camel-core,camel-jms,camel-spring)

在春季升级之前,配置工作正常,如果提供的信息不清楚,请告知我。

下面是我们项目中使用的当前依赖项。

春季4.3.0, camel-core-2.6.0, camel-jms-2.6.0, 骆驼泉2.6.0, activemq-console-5.3.0.3a, activemq-core-5.3.0.3a, activemq-pool-5.3.0.3a, kahadb-fuse-5.3.0.3a, activemq-camel-fuse-5.3.0.3a

骆驼上下文配置如下:

    <beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.apache.org/schema/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.3.0.xsd   
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">


    <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="deadLetterErrorHandler">
        <route>
            <from uri="embeddedActiveMQ:DYNAMIC.INTERNAL.QUEUE?concurrentConsumers=3&amp;maxConcurrentConsumers=100&amp;cacheLevelName=CACHE_CONSUMER&amp;maxMessagesPerTask=-1"/>
            <to uri="dynamicRouter"/>
        </route>
    </camelContext>

    <!-- Dynamic router bean delivers to external (message bus) component -->
    <bean id="dynamicRouter" class="com.messagebus.client.DynamicEmbeddedRouter">
        <constructor-arg index="0">
            <value>aiAuditAMQ</value>
        </constructor-arg>
    </bean>

</beans>

DynamicEmbeddedRouter.java

    import java.util.UUID;
 import org.apache.camel.Exchange;
 import org.apache.camel.Header;
 import org.apache.camel.Message;
 import org.apache.camel.RecipientList;

 public class DynamicEmbeddedRouter
 {
   private String endpoint;

   public DynamicEmbeddedRouter(String endpointName)
   {
    endpoint = (endpointName + ":");
   }

   @RecipientList
   public String routeMessage(@Header(name="JMSCorrelationID") String destName, Exchange exchange) {
     String destination = endpoint + destName;

     exchange.getIn().setHeader("JMSCorrelationID", UUID.randomUUID().toString());
     return destination;
   }
 }

以下是我们在升级jar之后看到的错误:

org.apache.camel.FailedToCreateRouteException: Failed to create route route at: >>> To[dynamicRouter] <<< in route: Route[[From[embeddedActiveMQ:DYNAMIC.INTERNAL.QUEUE?concurre... because of Failed to resolve endpoint: dynamicRouter due to: org.apache.camel.Header missing element value
        at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:759)
        at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:160)
        at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:701)
        at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1623)
        at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1412)
        at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1321)
        at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:164)
        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:65)
        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
        at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1299)
        at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:203)
        at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)
        ... 118 more
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: dynamicRouter due to: org.apache.camel.Header missing element value
        at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:449)
        at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:47)
        at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:175)
        at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:110)
        at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:116)
        at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:64)
        at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:58)
        at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:403)
        at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:174)
        at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:756)
        ... 129 more
Caused by: java.lang.annotation.IncompleteAnnotationException: org.apache.camel.Header missing element value
        at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:81)
        at com.sun.proxy.$Proxy85.value(Unknown Source)
        at org.apache.camel.component.bean.BeanInfo.createParameterUnmarshalExpressionForAnnotation(BeanInfo.java:619)
        at org.apache.camel.component.bean.BeanInfo.createParameterUnmarshalExpression(BeanInfo.java:599)
        at org.apache.camel.component.bean.BeanInfo.createMethodInfo(BeanInfo.java:303)
        at org.apache.camel.component.bean.BeanInfo.introspect(BeanInfo.java:219)
        at org.apache.camel.component.bean.BeanInfo.introspect(BeanInfo.java:196)
        at org.apache.camel.component.bean.BeanInfo.<init>(BeanInfo.java:94)
        at org.apache.camel.component.bean.BeanProcessor.<init>(BeanProcessor.java:56)
        at org.apache.camel.component.bean.BeanProcessor.<init>(BeanProcessor.java:60)
        at org.apache.camel.spring.SpringCamelContext.convertBeanToEndpoint(SpringCamelContext.java:193)
        at org.apache.camel.impl.DefaultCamelContext.createEndpoint(DefaultCamelContext.java:1981)
        at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:441)
        ... 138 more

请帮助我解决此错误。

0 个答案:

没有答案