Java Reference
In-Depth Information
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-
jms-1.0.xsd">
<context:annotation-config/>
<beans:bean id="connectionFactory" class="org.springframework.
jms.connection.CachingConnectionFactory">
<beans:property name="targetConnectionFactory">
<beans:bean class="org.apache.activemq.ActiveMQConnectionFactory">
<beans:property name="brokerURL" value=" tcp://localhost:8753"/>
</beans:bean>
</beans:property>
<beans:property name="sessionCacheSize" value="10"/>
<beans:property name="cacheProducers" value="false"/>
</beans:bean>
<beans:bean id="inboundHelloWorldJMSPingServiceActivator"
class="com.apress.springenterpriserecipes.springintegration.
InboundHelloWorldJMSMessageProcessor"/>
<channel id="inboundHelloJMSMessageChannel"/>
<jms:message-driven-channel-adapter
channel="inboundHelloJMSMessageChannel"
extract-payload="true"
connection-factory="connectionFactory"
destination-name="solution011"/>
<service-activator input-channel="inboundHelloJMSMessageChannel"
ref="inboundHelloWorldJMSPingServiceActivator"/>
</beans:beans>
As you can see, the most intimidating part is the schema import! The rest of the code is standard
boilerplate. You define a connectionFactory exactly as if you were configuring a standard MDP.
Then you define the salient beans specific to this solution: first, a bean that responds to messages
coming in to the bus from the message queue, inboundHelloWorldJMSPingServiceActivator . A service-
activator is a generic endpoint in Spring Integration that's used to invoke functionality_whether it be an
operation in a service, or some routine in a regular POJO, or anything you want instead_in response to a
message. Although this will be covered in some detail, it's interesting here only because you are using it
to respond to messages. These beans taken together are the collaborators in the solution, and this
example is fairly representative of how most integrations look: you define your collaborating
components; then you define the configuration using Spring Integration schema that configures the
solution itself.
The configuration starts with the inboundHelloJMSMessageChannel channel, which tells Spring
Integration what to name the point-to-point connection from the message queue to the service-
activator . You typically define a new channel for every point-to-point connection.
Search WWH ::




Custom Search