Apache Camel is designed to work nicely with the Spring Framework in a number of ways.
You can configure a CamelContext inside any spring.xml using the CamelContextFactoryBean. This will automatically start the CamelContext along with any referenced Routes along any referenced Component and Endpoint instances.
Using Spring you can configure Routes in two ways
You can use Java Code to define your RouteBuilder implementations, then in your spring.xml you can specify the Java package names to search for (recursively) to find your routes such as in the following example.
{snippet:id=example|lang=xml|url=activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/camel_context_factory_bean_test.xml} |
Or if you prefer you can use the Spring 2.0 XML Namespaces approach
{snippet:id=example3|lang=xml|url=activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/camel_context_factory_bean_test.xml} |
You can use Spring 2.0 XML configuration to specify your Xml Configuration for Routes such as in the following example.
{snippet:id=example|lang=xml|url=activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/routingUsingCamelContextFactoryWithNamespacesTest.xml} |