使用蓝图XML DSL的Camel DataFormat Jackson引发上下文异常

GLM*_*lls 0 json dataformat apache-camel jackson spring-camel

无论我将数据格式放在XML DSL蓝图中的何处,都会在不同的地方开始出现此错误。如果删除它,它可以工作,但是我当然不能将JSON转换为POJO。??? 任何帮助或告诉我我在做错什么,我在想什么。谢谢!

错误

Unable to start blueprint container for bundle passthrumt1.core/1.0.1.SNAPSHOT
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'endpoint'. One of '{"http://camel.apache.org/schema/blueprint":redeliveryPolicyProfile, "http://camel.apache.org/schema/blueprint":onException, "http://camel.apache.org/schema/blueprint":onCompletion, "http://camel.apache.org/schema/blueprint":intercept, "http://camel.apache.org/schema/blueprint":interceptFrom, "http://camel.apache.org/schema/blueprint":interceptSendToEndpoint, "http://camel.apache.org/schema/blueprint":restConfiguration, "http://camel.apache.org/schema/blueprint":rest, "http://camel.apache.org/schema/blueprint":route}' is expected.
Run Code Online (Sandbox Code Playgroud)

XML DSL

   <camelContext     
      id="com.passthru.coreCamelContext"
      trace="true"
      xmlns="http://camel.apache.org/schema/blueprint"
      allowUseOriginalMessage="false"
      streamCache="true"
      errorHandlerRef="deadLetterErrorHandler" >

    <properties>
        <property key="http.proxyHost" value="PITC-Zscaler-Americas.proxy.corporate.com"/>
        <property key="http.proxyPort" value="80"/>
    </properties>

    <streamCaching  id="CacheConfig" 
                    spoolUsedHeapMemoryThreshold="70" 
                    anySpoolRules="true"/>
<!--  -->
    <dataFormats>
            <json id="Json2Pojo" library="Jackson" unmarshalTypeName="com.passthru.core.entities.TokenEntities">
            </json>
    </dataFormats>

    <endpoint id="predixConsumer" uri="direct:preConsumer" />
    <endpoint id="predixProducer" uri="direct:preProducer" />
    <endpoint id="getToken" uri="direct:getToken" />

      <onException>
        <exception>com.passthru.dataservice.PDXDataServiceInvalidDataException</exception>
        <redeliveryPolicy maximumRedeliveries="3" />
        <handled>
          <constant>true</constant>
        </handled>
        <log
          message="Invalid Data From Data Service"
          loggingLevel="ERROR" />
        <setBody>
          <simple>${body.toString}</simple>
        </setBody>
        <to uri="file:{{errorArchive}}" />
      </onException>
Run Code Online (Sandbox Code Playgroud)

如果将数据格式放在属性之上,它会抱怨,我必须删除属性和streamcache语句才能使其正常工作。但是我需要代理属性。有什么建议么???再次感谢

如果

<camelContext     
  id="com.ge.digital.passthru.coreCamelContext"
  trace="true"
  xmlns="http://camel.apache.org/schema/blueprint"
  allowUseOriginalMessage="false"
  streamCache="true"
  errorHandlerRef="deadLetterErrorHandler" >
<dataFormats>
    <json id="Json2Pojo" library="Jackson" unmarshalTypeName="com.passthru.core.entities.TokenEntities"/>
</dataFormats>
<properties>
    <property key="http.proxyHost" value="PITC-Zscaler-Americas-Cincinnati3PR.proxy.corporate.com"/>
    <property key="http.proxyPort" value="80"/>
</properties>
Run Code Online (Sandbox Code Playgroud)

我明白了

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'properties'. One of '{"http://camel.apache.org/schema/blueprint":redeliveryPolicyProfile, "http://camel.apache.org/schema/blueprint":onException, "http://camel.apache.org/schema/blueprint":onCompletion, "http://camel.apache.org/schema/blueprint":intercept, "http://camel.apache.org/schema/blueprint":interceptFrom, "http://camel.apache.org/schema/blueprint":interceptSendToEndpoint, "http://camel.apache.org/schema/blueprint":restConfiguration, "http://camel.apache.org/schema/blueprint":rest, "http://camel.apache.org/schema/blueprint":route}' is expected.
Run Code Online (Sandbox Code Playgroud)

我想念什么?

Bed*_*dla 5

骆驼蓝图XML已针对camel-blueprint.xsd进行了验证。您对名称复杂的类型感兴趣,camelContextFactoryBean该名称包含具有固定顺序的可用元素序列。

按此顺序定义的camelContext元素的正确顺序是:

  • 属性
  • globalOptions
  • propertyPlaceholder
  • 包裹扫描
  • contextScan
  • jmxAgent
  • streamCaching
  • 出口
  • defaultServiceCallConfiguration
  • serviceCallConfiguration
  • defaultHystrixConfiguration
  • hystrixConfiguration
  • routeBuilder
  • routeContextRef
  • restContextRef
  • threadPoolProfile
  • 线程池
  • 终点
  • dataFormats
  • 变形金刚
  • 验证者
  • redeliveryPolicyProfile
  • onException
  • 在完成的时候
  • 截距
  • 拦截自
  • InterceptSendToEndpoint
  • restConfiguration
  • 休息
  • 路线

为了解决您的问题,请将所有endpoint声明移到上方dataFormats