Apache Camel Unmarshal for Singleton Scoped Bean
I am using Spring as my Bean Registry and currently I have a route defined with Java DSL like this:
@Override
public void configure() throws Exception {
from("netty:tcp://{{netty.host}}:{{netty.port}}?sync=false")
.routeId("pbxToBean").unmarshal("castor").to("mock:result");
}
It takes the XML marshaled input from the Netty endpoint and drops it down to the PBX bean.
I thought I could declare my PBX Bean result as a Singleton, and Camel passes the Unmarshalled object to the processor, which then updates the said singleton bean. Will this work?
+3
source to share
1 answer
Yes, if casor is a bean linked in the registry,
/**
* <a href="http://camel.apache.org/data-format.html">DataFormat:</a>
* Unmarshals the in body using the specified {@link DataFormat}
* reference in the {@link org.apache.camel.spi.Registry} and sets
* the output on the out message body.
*
* @param dataTypeRef reference to a {@link DataFormat} to lookup in the registry
* @return the builder
*/
@SuppressWarnings("unchecked")
public Type unmarshal(String dataTypeRef) {
addOutput(new UnmarshalDefinition(dataTypeRef));
return (Type) this;
}
+1
source to share