failedtocreaterouteexception:未能创建路由at:>>>setheader[null,constant{}]< < < 路由中:因为必须指定headername

2mbi3lxu  于 2021-06-27  发布在  Java
关注(0)|答案(1)|浏览(431)

我正在创建一条这样的路线:

<routes xmlns="http://camel.apache.org/schema/spring">
   <route id="ESP_01.Handle_Movement">
      <from uri="mqtt:ESP_01.Handle_Movement?host=tcp://localhost:1883&amp;subscribeTopicName=ESP_01/Handle Movement&amp;version=3.1&amp;maxReadRate=0&amp;qualityOfService=AtLeastOnce" />
      <to uri="micrometer:timer:camel.proxy.mqtt.kafka.stream?action=start" />
      <to uri="log://camel.proxy?groupInterval=3&amp;level=INFO" />
      <to uri="kafka://ESP_01.Handle_Movement?brokers=localhost:9092" />
      <to uri="micrometer:timer:camel.proxy.mqtt.kafka.stream?action=stop" />
      <to uri="micrometer:timer:camel.proxy.cache?action=start" />
      <setHeader name="CamelCacheKey">
         <constant>Test ESP_01.Handle_Movement</constant>
      </setHeader>
      <setHeader name="CamelCacheOperation">
         <constant>Update</constant>
      </setHeader>
      <to uri="cache://Test ESP_01.Handle_Movement?maxElementsInMemory=10&amp;eternal=true" />
      <to uri="micrometer:timer:camel.proxy.cache?action=stop" />
   </route>
</routes>

我有

<setHeader name="CamelCacheKey">
         <constant>Test ESP_01.Handle_Movement</constant>
      </setHeader>
      <setHeader name="CamelCacheOperation">
         <constant>Update</constant>
      </setHeader>

但是,根据这个示例,我从title得到的错误消息是,缺少了required already existing name参数:

org.apache.camel.FailedToCreateRouteException: Failed to create route ESP_01.Handle_Movement at: >>> SetHeader[null, constant{Test ESP_01.Handle_Movement}] <<< in route: Route(ESP_01.Handle_Movement)[[From[mqtt:ESP_01.Handle_Movem... because of headerName must be specified
yacmzcpb

yacmzcpb1#

这可能是由于<camel.version>2.24.3的bug造成的
在spring dsl中,验证的参数是 name ,而在标头的类中,参数名为 headerName ,设置为空。如果我尝试使用 headerName spring dsl中的参数我得到这个错误:

"org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 633; cvc-complex-type.3.2.2: Attribute 'headerName' is not allowed to appear in element 'setHeader'.",

相关问题