Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
h2. Spring Integration Component

The *spring-integration:* component provides a bridge for Camel components to talk to [spring integration endpoints|http://camel.apache.org/springintegration.html].

Maven users will need to add the following dependency to their {{pom.xml}} for this component:
{code:xml}
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring-integration</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
{code}

h3. URI format

{code}
spring-integration:defaultChannelName[?options]
{code}
Where *defaultChannelName* represents the default channel name which is used by the Spring Integration Spring context. It will equal to the {{inputChannel}} name for the Spring Integration consumer and the {{outputChannel}} name for the Spring Integration provider.

You can append query options to the URI in the following format, {{?option=value&option=value&...}}

h3. Options
{div:class=confluenceTableSmall}
|| Name || DescriptionType || Example || Required Description || Default Value ||
| {{inputChannel}} | String | The Spring integration input channel name that this endpoint wants to consume from, where the specified channel name is defined in the Spring context. | {{inputChannel=requestChannel}} | No |  |
| {{outputChannel}} | String | The Spring integration output channel name that is used to send messages to the Spring integration context. | {{outputChannel=replyChannel}} | No | |
| {{inOut}} | String | The exchange pattern that the Spring integration endpoint should use. |If {{inOut=true}} |then Noa | {{inOnly}} for the Spring integration consumer and {{outOnly}} for reply channel is expected, either from the Spring integrationIntegration providerMessage |
| {{consumer.delay}} | Delay in milliseconds between each poll. | {{consumer.delay=60000}} | No | {{500}} |	 
| {{consumer.initialDelay}} | Milliseconds before polling starts. | {{consumer.initialDelay=10000}} | No | {{1000}} |
| {{consumer.userFixedDelay}} | Specify {{true}} to use fixed delay between polls, otherwise fixed rate is used. See the Java[ScheduledExecutorService|http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/lang/Character.html] class for details. | {{consumer.userFixedDelay=false}} | No | {{false}} |header or configured on the endpoint. | 
{div}

h3. Usage

The Spring integration component is a bridge that connects Camel endpoints with Spring integration endpoints through the Spring integration's input channels and output channels. Using this component, we can send Camel messages to Spring Integration endpoints or receive messages from Spring integration endpoints in a Camel routing context.

h3. Examples

h4. Using the Spring integration endpoint
You can set up a Spring integration endpoint using a URI, as follows: 

{snippet:id=example|lang=xml|url=camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/producer.xml}

{snippet:id=example|lang=xml|url=camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/twoWayConsumer.xml}

Or directly using a Spring integration channel name:

{snippet:id=example|lang=xml|url=camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/springChannelConverter.xml}

h4. The Source and Target adapter

Spring integration also provides the Spring integration's source and target adapters, which can route messages from a Spring integration channel to a Camel endpoint or from a Camel endpoint to a Spring integration channel.

This example uses the following namespaces:

{snippet:id=header|lang=xml|url=camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelTarget.xml}

You can bind your source or target to a Camel endpoint as follows:

{snippet:id=example|lang=xml|url=camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelTarget.xml}

{snippet:id=example|lang=xml|url=camel/trunk/components/camel-spring-integration/src/test/resources/org/apache/camel/component/spring/integration/adapter/CamelSource.xml}


{include:Endpoint See Also}