Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
561 views
in Technique[技术] by (71.8m points)

java - FailedToCreateRouteException: Failed to create route.. at: >>> SetHeader[null, constant{}] <<< in route: because of headerName must be specified

I'm creating a route like that:

<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>

I have

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

according to the example, however I'm getting the error message from the title that required already existing name parameter is missed:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That's probably due to the bug of <camel.version>2.24.3</camel.version>

In Spring DSL the validated parameter is name, while in the class of the header the parameter name is headerName, that is set to null. If I try to use headerName parameter in Spring DSL I'm getting this error:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...