3
votes

I'm using Spring as my Bean registry and I currently have a route defined with the Java DSL as follows:

@Override
public void configure() throws Exception {
   from("netty:tcp://{{netty.host}}:{{netty.port}}?sync=false")
         .routeId("pbxToBean").unmarshal("castor").to("mock:result");
}

It takes an XML marshaled input from a Netty endpoint and unmarshalls it to a PBX bean.

I was thinking I could declare my result PBX bean as a Singleton and have Camel pass an unmarshalled object to a Processor which then updates said singleton bean. Would this work?

1

1 Answers

1
votes

Yes, if casor is a bean bound 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;
}