Reputation: 1329
I have a maven project, and I'm trying to marshal a file using jaxb and camel with the command:
from("file://...").marshal("myDataFormat").to("file://...");
When I run the project, I get the following error:
Cannot find data format in registry with ref: myDataFormat
First, does anyone know what the "registry" is? I've searched Google, but can't find anything. I'm guessing it might be another name for the camel-context file. Second, how can I register a data format using camel? Is there a default data format that I can use?
Sorry if the answer is simple, but I'm relatively new to camel and the online docs that I can find haven't been too helpful.
Upvotes: 0
Views: 2658
Reputation: 1771
About Camel registry http://camel.apache.org/registry.html
For simple, test task Simple registry will be fine.
Spring or Blueprint is good for more complex tasks. http://camel.apache.org/using-osgi-blueprint-with-camel.html , http://camel.apache.org/spring.html , http://camel.apache.org/data-format.html (see Spring example below page)
Blueprint context example, with some data formats.
<?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>
Simple registry example.
public static SimpleRegistry createRegistry() {
SimpleRegistry simpleRegistry = new SimpleRegistry();
simpleRegistry.put("transformerFactory", com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.class);
simpleRegistry.put("javaUuidGenerator", org.apache.camel.impl.JavaUuidGenerator.class);
return simpleRegistry;
}
public void createCamelContext() {
logger.info("Create Camel context");
simpleRegistry = createRegistry();
defaultCamelContext = new DefaultCamelContext(simpleRegistry);
}
Upvotes: 1
Reputation: 128
You should use something like this
DataFormat jaxb = new JaxbDataFormat("com.acme.model");
from("activemq:My.Queue").
unmarshal(jaxb).
to("mqseries:Another.Queue");
In other words, first create dataformat object then try to unmarshal it.
Upvotes: 3