Java 在注册表中找不到数据格式-Camel
我有一个maven项目,我正在尝试使用jaxb和camel命令封送一个文件:Java 在注册表中找不到数据格式-Camel,java,maven,jaxb,apache-camel,Java,Maven,Jaxb,Apache Camel,我有一个maven项目,我正在尝试使用jaxb和camel命令封送一个文件: from("file://...").marshal("myDataFormat").to("file://..."); 当我运行项目时,出现以下错误: Cannot find data format in registry with ref: myDataFormat 首先,有人知道什么是“注册表”吗?我搜索过谷歌,但什么也找不到。我猜它可能是camel上下文文件的另一个名称。第二,如何使用camel注册数据格式
from("file://...").marshal("myDataFormat").to("file://...");
当我运行项目时,出现以下错误:
Cannot find data format in registry with ref: myDataFormat
首先,有人知道什么是“注册表”吗?我搜索过谷歌,但什么也找不到。我猜它可能是camel上下文文件的另一个名称。第二,如何使用camel注册数据格式?是否有可以使用的默认数据格式
如果答案很简单,很抱歉,但我对camel比较陌生,而且我能找到的在线文档没有太大帮助。您应该使用类似的内容
DataFormat jaxb = new JaxbDataFormat("com.acme.model");
from("activemq:My.Queue").
unmarshal(jaxb).
to("mqseries:Another.Queue");
换句话说,首先创建dataformat对象,然后尝试将其解组。您应该使用类似的方法
DataFormat jaxb = new JaxbDataFormat("com.acme.model");
from("activemq:My.Queue").
unmarshal(jaxb).
to("mqseries:Another.Queue");
换句话说,首先创建dataformat对象,然后尝试将其解组。关于Camel注册表
对于简单,测试任务简单注册表就可以了
Spring或Blueprint适用于更复杂的任务,(参见第页下面的Spring示例)
Blueprint上下文示例,包含一些数据格式
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xsi:schemaLocation=
"http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<camelContext id="camelTest"
xmlns="http://camel.apache.org/schema/blueprint" >
<propertyPlaceholder id="properties" location="blueprint:server.placeholder"/>
<package>camel.test</package>
<dataFormats>
<beanio id="cashWarrantFormat" mapping="beanio/mapping.xml" streamName="CashWarrant" encoding="UTF-8"/>
<beanio id="metaDocFormat" mapping="beanio/mapping.xml" streamName="MetaDoc" encoding="UTF-8"/>
<beanio id="accStatementFormat" mapping="beanio/mapping.xml" streamName="AccStatement" encoding="UTF-8"/>
<beanio id="advanceReport" mapping="beanio/mapping.xml" streamName="AdvanceReport" encoding="UTF-8"/>
</dataFormats>
</camelContext>
<bean id="javaUuidGenerator" class="org.apache.camel.impl.JavaUuidGenerator"/>
</blueprint>
关于骆驼注册中心
对于简单,测试任务简单注册表就可以了
Spring或Blueprint适用于更复杂的任务,(参见第页下面的Spring示例)
Blueprint上下文示例,包含一些数据格式
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xsi:schemaLocation=
"http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<camelContext id="camelTest"
xmlns="http://camel.apache.org/schema/blueprint" >
<propertyPlaceholder id="properties" location="blueprint:server.placeholder"/>
<package>camel.test</package>
<dataFormats>
<beanio id="cashWarrantFormat" mapping="beanio/mapping.xml" streamName="CashWarrant" encoding="UTF-8"/>
<beanio id="metaDocFormat" mapping="beanio/mapping.xml" streamName="MetaDoc" encoding="UTF-8"/>
<beanio id="accStatementFormat" mapping="beanio/mapping.xml" streamName="AccStatement" encoding="UTF-8"/>
<beanio id="advanceReport" mapping="beanio/mapping.xml" streamName="AdvanceReport" encoding="UTF-8"/>
</dataFormats>
</camelContext>
<bean id="javaUuidGenerator" class="org.apache.camel.impl.JavaUuidGenerator"/>
</blueprint>