Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » Java » EJB » Downloads
 
Add your own
alternative version

Spring Integration with ActiveMQ for POJO Based Service

, 25 Aug 2010 GPL3
How to use Spring Integration with ActiveMQ to handle message in pure POJO
SpringIntegrationWithSOAP.zip
SpringIntegrationSOAP
.classpath
.project
src
main
java
org
soap
demo
resources
org
soap
demo
payload.xsl
<?xml version="1.0" encoding="UTF-8"?>
<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"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jms="http://www.springframework.org/schema/integration/jms"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
			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-2.0.xsd
			http://www.springframework.org/schema/integration/jms
			http://www.springframework.org/schema/integration/jms/spring-integration-jms-2.0.xsd">

	<gateway id="gateway1" default-request-channel="jmsChannel"
		service-interface="org.soap.demo.SampleGateway" />

	<jms:outbound-gateway request-channel="jmsChannel"
		request-destination="requestQueue" />

	<jms:inbound-gateway request-destination="requestQueue"
		request-channel="demoChannel" />

	<chain input-channel="demoChannel">
		<!-- Route the request to proper channel based on operation specified in Envelope Header -->	
		<router>
			<beans:bean
				class="org.springframework.integration.xml.router.XPathSingleChannelRouter">
				<beans:constructor-arg value="//operation" /> <!-- TODO: XPath Expression can be made better here :) -->
			</beans:bean>
		</router>
	</chain>

	<chain input-channel="add">	
		<!-- Extract Request Payload from Envelope Body -->
		<transformer>		
			<beans:bean class="org.springframework.integration.xml.transformer.XsltPayloadTransformer">
			    <beans:constructor-arg value="classpath:org/soap/demo/payload.xsl" />
			    <beans:constructor-arg>
			        <beans:bean class="org.springframework.integration.xml.transformer.ResultToStringTransformer" />
			    </beans:constructor-arg>
			</beans:bean>
		</transformer>
		<!-- Create a Java Request object from xml obtained -->
		<transformer>
			<beans:bean class="org.springframework.integration.xml.transformer.UnmarshallingTransformer">
    			<beans:constructor-arg>
        			<beans:bean class="org.springframework.oxm.castor.CastorMarshaller">
		    			<beans:property name="mappingLocation" value="classpath:org/soap/demo/mapping.xml" />
        			</beans:bean>
    			</beans:constructor-arg>
			</beans:bean>
		</transformer>
		<!-- Do the service and return result -->
		<service-activator >
			<beans:bean class="org.soap.demo.Service" />
		</service-activator>
		<!-- Add transformers to convert to SOAP response Envelope -->		
	</chain>

	<beans:import resource="/org/soap/demo/jms.xml" />

</beans:beans>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Share

About the Author

anand kr
Software Developer (Senior)
India India
Specialization in Java/J2EE/JSF/Richfaces/Spring/Spring Integration
Area of interest: Refactoring with design patterns.
Currently working on Spring Integration and ActiveMQ.
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141216.1 | Last Updated 25 Aug 2010
Article Copyright 2010 by anand kr
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid