Skip to main content

Using Spring configuration

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 Spring website.

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 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.

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="">
    <property name="location" value=""/>

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 vm:a to log:vm:

		<camel:from uri="vm:a" />
		<camel:to uri="log:vm" />

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 SEDA (Mediation).

Information noteWarning:

When the Spring configuration is wrong, the Route may fail to start.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!