The spring-integration: component provides a bridge for FUSE Mediation Router components to talk to spring integration endpoints.
spring-integration:defaultChannelName[?options]
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.
Name | Description | Example | Required | default value |
---|---|---|---|---|
inputChannel | The spring integration input channel name this endpoint wants to consume from that is defined in the spring context | inputChannel=requestChannel | No | |
outputChannel | The spring integration output channel name to send message to the spring integration context | outputChannel=replyChannel | No | |
inOut | The exchange pattern that spring integration endpoint should use | inOut=true | No | inOnly for the spring integration consumer and outOnly for the spring integration provider |
consumer.delay | Delay in millis between each poll | consumer.delay=60000 | No | 500 |
consumer.initialDelay | Millis before polling starts | consumer.initialDelay=10000 | No | 1000 |
consumer.userFixedDelay | true to use fixed delay between pools, otherwise fixed rate is used. See ScheduledExecutorService in JDK for details. | consumer.userFixedDelay=false | No | false |
Spring Integration component is a bridge which connects Spring Integration endpoints through the Spring integration's input and output channels with the Camel endpoints. In this way, we can send out the Camel message to Spring Integration endpoints or receive the message from Spring Integration endpoint in Camel routing context.
You could setup the Spring Integration Endpoint by using the URI
<beans:beans xmlns="http://www.springframework.org/schema/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <channel id="inputChannel"/> <channel id="outputChannel"/> <channel id="onewayChannel"/> <service-activator input-channel="inputChannel" ref="helloService" method="sayHello"/> <service-activator input-channel="onewayChannel" ref="helloService" method="greet"/> <beans:bean id="helloService" class="org.apache.camel.component.spring.integration.HelloWorldService"/> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:twowayMessage"/> <!-- Using the & as the separator of & --> <to uri="spring-integration:inputChannel?inOut=true&inputChannel=outputChannel"/> </route> <route> <from uri="direct:onewayMessage"/> <to uri="spring-integration:onewayChannel?inOut=false"/> </route> </camelContext>
<channel id="requestChannel"/> <channel id="responseChannel"/> <beans:bean id="myProcessor" class="org.apache.camel.component.spring.integration.MyProcessor"/> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <!-- Using the & as the separator of & --> <from uri="spring-integration://requestChannel?outputChannel=responseChannel&inOut=true"/> <process ref="myProcessor"/> </route> </camelContext>
or by the Spring Integration Channel name
<beans:beans xmlns="http://www.springframework.org/schema/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <channel id="outputChannel"/> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <!-- camel will create a spring integration endpoint automatically --> <from uri="outputChannel"/> <to uri="mock:result"/> </route> </camelContext>
Spring Integartion also provides the Spring Integration's Source and Target adapters which could route the message from the Spring Integration channel to a camel context endpoint or from a camel context endpoint to a Spring Integration Channel.
Here is the name spaces header
<beans:beans xmlns="http://www.springframework.org/schema/integration" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel-si="http://camel.apache.org/schema/spring/integration" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd http://camel.apache.org/schema/spring/integration http://camel.apache.org/schema/spring/integration/camel-spring-integration.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd ">
Now you could bind your source or target to camel context endpoint
<!-- Create the camel context here --> <camelContext id="camelTargetContext" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:EndpointA" /> <to uri="mock:result" /> </route> <route> <from uri="direct:EndpointC"/> <process ref="myProcessor"/> </route> </camelContext> <!-- We can bind the camelTarget to the camel context's endpoint by specifying the camelEndpointUri attribute --> <camel-si:camelTarget id="camelTargetA" camelEndpointUri="direct:EndpointA" expectReply="false"> <camel-si:camelContextRef>camelTargetContext</camel-si:camelContextRef> </camel-si:camelTarget> <camel-si:camelTarget id="camelTargetB" camelEndpointUri="direct:EndpointC" replyChannel="channelC" expectReply="true"> <camel-si:camelContextRef>camelTargetContext</camel-si:camelContextRef> </camel-si:camelTarget> <camel-si:camelTarget id="camelTargetD" camelEndpointUri="direct:EndpointC" expectReply="true"> <camel-si:camelContextRef>camelTargetContext</camel-si:camelContextRef> </camel-si:camelTarget> <beans:bean id="myProcessor" class="org.apache.camel.component.spring.integration.MyProcessor"/>
<camelContext id="camelSourceContext" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:OneWay"/> <to uri="direct:EndpointB" /> </route> <route> <from uri="direct:TwoWay"/> <to uri="direct:EndpointC" /> </route> </camelContext> <!-- camelSource will redirect the message coming for direct:EndpointB to the spring requestChannel channelA --> <camel-si:camelSource id="camelSourceA" camelEndpointUri="direct:EndpointB" requestChannel="channelA" expectReply="false"> <camel-si:camelContextRef>camelSourceContext</camel-si:camelContextRef> </camel-si:camelSource> <!-- camelSource will redirect the message coming for direct:EndpointC to the spring requestChannel channelB then it will pull the response from channelC and put the response message back to direct:EndpointC --> <camel-si:camelSource id="camelSourceB" camelEndpointUri="direct:EndpointC" requestChannel="channelB" replyChannel="channelC" expectReply="true"> <camel-si:camelContextRef>camelSourceContext</camel-si:camelContextRef> </camel-si:camelSource>