Spring is an application development framework for enterprise Java. Apache Camel is designed to work nicely with the Spring Framework. The Route designer of Talend Studio allows you to add a Spring context to a Route for configuration purpose. You can define beans and resources in Spring XML DSL and then use them in Routes. This makes it possible for developers to combine Java and Spring codes in the configuration of Routes. It is particularly useful when there is no explicit component available in the palette.
To be able to use the Spring configuration, your knowledge of Spring is required. For more information about Spring, see the site http://www.springsource.org/. For the Spring support of Apache Camel, see http://camel.apache.org/spring.html.
To add a Spring context to a Route, you need first to create the Route. For more information about how to create a Route, see Creating a Route.
The Spring tab is located in the lower half of the design workspace. When you create a Route in the design workspace, a default Spring configuration is set in the Spring view.
By default, the Apache Camel JMX Notification is declared in the Spring configuration. You can configure it as needed and call it in the Route. For more information about Apache Camel JMX Notification, see http://camel.apache.org/camel-jmx.html.
Enter the code you want to implement in this view. The screenshot above shows an example of using a bean to call a previously defined Route Resource named RouteWithSpring:
<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"> <property name="location" value="classpath:RouteWithSpring.properties"/> </bean>
For more information about creating and using Route Resources, see Using Route Resources.
The following code gives another example that defines a message routing from the endpoint
<camel:camelContext> <camel:route> <camel:from uri="vm:a" /> <camel:to uri="log:vm" /> </camel:route> </camel:camelContext>
When you export a Route, the Spring XML file will be also exported in the KAR file.
Click the Restore Default button to change back to the default Spring configuration.
For a real-life use case of how to use Spring configuration in a Route, see the scenario provided for cSEDA in cSEDA .
When the Spring configuration is wrong, the Route may fail to start.