diff --git a/case-studies/loan-broker/README.txt b/case-studies/loan-broker/readme.txt
similarity index 100%
rename from case-studies/loan-broker/README.txt
rename to case-studies/loan-broker/readme.txt
diff --git a/case-studies/loan-broker/src/main/resources/bank-channel-mappings-config.xml b/case-studies/loan-broker/src/main/resources/META-INF/spring/integration/bank-channel-mappings-config.xml
similarity index 100%
rename from case-studies/loan-broker/src/main/resources/bank-channel-mappings-config.xml
rename to case-studies/loan-broker/src/main/resources/META-INF/spring/integration/bank-channel-mappings-config.xml
diff --git a/case-studies/loan-broker/src/main/resources/META-INF/spring/integration/bootstrap-config/stubbed-loan-broker-multicast.xml b/case-studies/loan-broker/src/main/resources/META-INF/spring/integration/bootstrap-config/stubbed-loan-broker-multicast.xml
new file mode 100644
index 00000000..0aecda95
--- /dev/null
+++ b/case-studies/loan-broker/src/main/resources/META-INF/spring/integration/bootstrap-config/stubbed-loan-broker-multicast.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
diff --git a/case-studies/loan-broker/src/main/resources/bootstrap-config/stubbed-loan-broker.xml b/case-studies/loan-broker/src/main/resources/META-INF/spring/integration/bootstrap-config/stubbed-loan-broker.xml
similarity index 52%
rename from case-studies/loan-broker/src/main/resources/bootstrap-config/stubbed-loan-broker.xml
rename to case-studies/loan-broker/src/main/resources/META-INF/spring/integration/bootstrap-config/stubbed-loan-broker.xml
index 5a0ddf44..9344d9d8 100644
--- a/case-studies/loan-broker/src/main/resources/bootstrap-config/stubbed-loan-broker.xml
+++ b/case-studies/loan-broker/src/main/resources/META-INF/spring/integration/bootstrap-config/stubbed-loan-broker.xml
@@ -3,8 +3,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-
-
+
+
+
diff --git a/case-studies/loan-broker/src/main/resources/loan-broker-config.xml b/case-studies/loan-broker/src/main/resources/META-INF/spring/integration/loan-broker-config.xml
similarity index 100%
rename from case-studies/loan-broker/src/main/resources/loan-broker-config.xml
rename to case-studies/loan-broker/src/main/resources/META-INF/spring/integration/loan-broker-config.xml
diff --git a/case-studies/loan-broker/src/main/resources/shark-detector-config.xml b/case-studies/loan-broker/src/main/resources/META-INF/spring/integration/shark-detector-config.xml
similarity index 100%
rename from case-studies/loan-broker/src/main/resources/shark-detector-config.xml
rename to case-studies/loan-broker/src/main/resources/META-INF/spring/integration/shark-detector-config.xml
diff --git a/case-studies/loan-broker/src/main/resources/stub-services-config.xml b/case-studies/loan-broker/src/main/resources/META-INF/spring/integration/stub-services-config.xml
similarity index 100%
rename from case-studies/loan-broker/src/main/resources/stub-services-config.xml
rename to case-studies/loan-broker/src/main/resources/META-INF/spring/integration/stub-services-config.xml
diff --git a/case-studies/loan-broker/src/main/resources/bootstrap-config/stubbed-loan-broker-multicast.xml b/case-studies/loan-broker/src/main/resources/bootstrap-config/stubbed-loan-broker-multicast.xml
deleted file mode 100644
index bb8b2142..00000000
--- a/case-studies/loan-broker/src/main/resources/bootstrap-config/stubbed-loan-broker-multicast.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/case-studies/loan-broker/src/test/java/org/springframework/integration/samples/loanbroker/demo/LoanBrokerDemo.java b/case-studies/loan-broker/src/test/java/org/springframework/integration/samples/loanbroker/demo/LoanBrokerDemo.java
index bf3f3918..9fcc8523 100644
--- a/case-studies/loan-broker/src/test/java/org/springframework/integration/samples/loanbroker/demo/LoanBrokerDemo.java
+++ b/case-studies/loan-broker/src/test/java/org/springframework/integration/samples/loanbroker/demo/LoanBrokerDemo.java
@@ -41,7 +41,7 @@ public class LoanBrokerDemo {
@Test
public void runDemo() {
- ApplicationContext context = new ClassPathXmlApplicationContext("bootstrap-config/stubbed-loan-broker.xml");
+ ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/integration/bootstrap-config/stubbed-loan-broker.xml");
LoanBrokerGateway broker = context.getBean("loanBrokerGateway", LoanBrokerGateway.class);
LoanRequest loanRequest = new LoanRequest();
loanRequest.setCustomer(new Customer());
diff --git a/case-studies/loan-broker/src/test/java/org/springframework/integration/samples/loanbroker/demo/LoanBrokerSharkDetectorDemo.java b/case-studies/loan-broker/src/test/java/org/springframework/integration/samples/loanbroker/demo/LoanBrokerSharkDetectorDemo.java
index baaa84f6..45251fa8 100644
--- a/case-studies/loan-broker/src/test/java/org/springframework/integration/samples/loanbroker/demo/LoanBrokerSharkDetectorDemo.java
+++ b/case-studies/loan-broker/src/test/java/org/springframework/integration/samples/loanbroker/demo/LoanBrokerSharkDetectorDemo.java
@@ -38,7 +38,7 @@ public class LoanBrokerSharkDetectorDemo {
@Test
public void testUdpMulticast() {
ConfigurableApplicationContext context =
- new ClassPathXmlApplicationContext("bootstrap-config/stubbed-loan-broker-multicast.xml");
+ new ClassPathXmlApplicationContext("META-INF/spring/integration/bootstrap-config/stubbed-loan-broker-multicast.xml");
LoanBrokerGateway broker = context.getBean("loanBrokerGateway", LoanBrokerGateway.class);
LoanRequest loanRequest = new LoanRequest();
loanRequest.setCustomer(new Customer());
diff --git a/case-studies/loan-broker/udps.groovy b/case-studies/loan-broker/udps.groovy
new file mode 100644
index 00000000..f9b69716
--- /dev/null
+++ b/case-studies/loan-broker/udps.groovy
@@ -0,0 +1,12 @@
+//Groovy Script to catch multicast packets.
+socket = new MulticastSocket(11111)
+mcast = InetAddress.getByName("225.6.7.8")
+socket.joinGroup(mcast)
+buffer = (' ' * 1024) as byte[]
+while(true) {
+ incoming = new DatagramPacket(buffer, buffer.length)
+ socket.receive(incoming)
+ s = new String(incoming.data, 0, incoming.length)
+ println ("** Shark **" + s)
+}
+
diff --git a/case-studies/loan-broker/udps.pl b/case-studies/loan-broker/udps.pl
new file mode 100755
index 00000000..ed00ed57
--- /dev/null
+++ b/case-studies/loan-broker/udps.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/perl -w
+#Perl Script to catch multicast packets.
+use strict;
+use IO::Socket::Multicast;
+
+my $socket = IO::Socket::Multicast->new(LocalPort=>11111, ReuseAddr=>1)
+ or die "Can't start UDP server: $@";
+
+$socket->mcast_add('225.6.7.8');
+
+my ($datagram,$flags);
+while ($socket->recv($datagram,1024,$flags)) {
+ print "**Shark** $datagram\n";
+}
+
+$socket->close();
diff --git a/cook-books/async-gateway/.classpath b/cook-books/async-gateway/.classpath
new file mode 100644
index 00000000..a9b8d563
--- /dev/null
+++ b/cook-books/async-gateway/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/cook-books/async-gateway/.gitignore b/cook-books/async-gateway/.gitignore
new file mode 100644
index 00000000..ea8c4bf7
--- /dev/null
+++ b/cook-books/async-gateway/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/cook-books/async-gateway/.project b/cook-books/async-gateway/.project
new file mode 100644
index 00000000..3897200b
--- /dev/null
+++ b/cook-books/async-gateway/.project
@@ -0,0 +1,29 @@
+
+
+ async-gateway
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.maven.ide.eclipse.maven2Builder
+
+
+
+
+ org.springframework.ide.eclipse.core.springbuilder
+
+
+
+
+
+ org.springframework.ide.eclipse.core.springnature
+ org.eclipse.jdt.core.javanature
+ org.maven.ide.eclipse.maven2Nature
+
+
diff --git a/cook-books/async-gateway/.settings/com.springsource.sts.config.flow.prefs b/cook-books/async-gateway/.settings/com.springsource.sts.config.flow.prefs
new file mode 100644
index 00000000..359e39c8
--- /dev/null
+++ b/cook-books/async-gateway/.settings/com.springsource.sts.config.flow.prefs
@@ -0,0 +1,3 @@
+#Thu Sep 16 13:45:10 EDT 2010
+//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/async-gateway/src/main/resources/META-INF/spring/integration/math-service-config.xml=\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
+eclipse.preferences.version=1
diff --git a/cook-books/async-gateway/.settings/org.maven.ide.eclipse.prefs b/cook-books/async-gateway/.settings/org.maven.ide.eclipse.prefs
new file mode 100644
index 00000000..28947cd0
--- /dev/null
+++ b/cook-books/async-gateway/.settings/org.maven.ide.eclipse.prefs
@@ -0,0 +1,9 @@
+#Fri Sep 03 11:06:43 EDT 2010
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
diff --git a/cook-books/async-gateway/.settings/org.springframework.ide.eclipse.core.prefs b/cook-books/async-gateway/.settings/org.springframework.ide.eclipse.core.prefs
new file mode 100644
index 00000000..ed4b8795
--- /dev/null
+++ b/cook-books/async-gateway/.settings/org.springframework.ide.eclipse.core.prefs
@@ -0,0 +1,68 @@
+#Fri Sep 03 10:29:08 EDT 2010
+eclipse.preferences.version=1
+org.springframework.ide.eclipse.core.builders.enable.aopreferencemodelbuilder=true
+org.springframework.ide.eclipse.core.builders.enable.beanmetadatabuilder=true
+org.springframework.ide.eclipse.core.builders.enable.osgibundleupdater=false
+org.springframework.ide.eclipse.core.enable.project.preferences=true
+org.springframework.ide.eclipse.core.validator.enable.com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.enable.com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.enable.com.springsource.sts.server.quickfix.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.core.springvalidator=false
+org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.applicationSymbolicNameRule-com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.applicationVersionRule-com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.bundleActivationPolicyRule-com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.bundleActivatorRule-com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.bundleManifestVersionRule-com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.bundleSymbolicNameRule-com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.bundleVersionRule-com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.exportPackageRule-com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.importRule-com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.parsingProblemsRule-com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.server.ide.manifest.core.requireBundleRule-com.springsource.server.ide.manifest.core.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.AvoidDriverManagerDataSource-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.ImportElementsAtTopRulee-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.ParentBeanSpecifiesAbstractClassRule-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.RefElementRule-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.TooManyBeansInFileRule-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.UnnecessaryValueElementRule-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.com.springsource.sts.bestpractices.UseBeanInheritance-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.bestpractices.legacyxmlusage.jndiobjectfactory-com.springsource.sts.bestpractices.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.server.quickfix.importBundleVersionRule-com.springsource.sts.server.quickfix.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.server.quickfix.importLibraryVersionRule-com.springsource.sts.server.quickfix.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.server.quickfix.importPackageVersionRule-com.springsource.sts.server.quickfix.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.com.springsource.sts.server.quickfix.requireBundleVersionRule-com.springsource.sts.server.quickfix.manifestvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.autowire.autowire-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanAlias-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanClass-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanConstructorArgument-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinition-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinitionHolder-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanFactory-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanInitDestroyMethod-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanReference-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.methodOverride-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.parsingProblems-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.requiredProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.toolAnnotation-org.springframework.ide.eclipse.beans.core.beansvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.core.springClasspath-org.springframework.ide.eclipse.core.springvalidator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.action-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.actionstate-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attribute-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attributemapper-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.beanaction-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationaction-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationresult-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.exceptionhandler-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.import-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.inputattribute-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.mapping-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.outputattribute-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.set-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.state-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.subflowstate-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.transition-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.variable-org.springframework.ide.eclipse.webflow.core.validator=false
+org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.webflowstate-org.springframework.ide.eclipse.webflow.core.validator=false
diff --git a/cook-books/async-gateway/.springBeans b/cook-books/async-gateway/.springBeans
new file mode 100644
index 00000000..15608f30
--- /dev/null
+++ b/cook-books/async-gateway/.springBeans
@@ -0,0 +1,13 @@
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
diff --git a/cook-books/async-gateway/pom.xml b/cook-books/async-gateway/pom.xml
new file mode 100644
index 00000000..266d9adf
--- /dev/null
+++ b/cook-books/async-gateway/pom.xml
@@ -0,0 +1,47 @@
+
+ 4.0.0
+ org.springframework.integration.samples
+ async-gateway
+ 2.0.0
+ Async Gateway Demo
+ jar
+
+ 2.0.0.M7
+ 1.2.15
+ 4.7
+
+
+
+ org.springframework.integration
+ spring-integration-core
+ ${spring.integration.version}
+
+
+ log4j
+ log4j
+ ${log4j.version}
+
+
+
+ junit
+ junit
+ ${junit.version}
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.5
+ 1.5
+ -Xlint:all
+ true
+ false
+
+
+
+
+
diff --git a/cook-books/async-gateway/readme.txt b/cook-books/async-gateway/readme.txt
new file mode 100644
index 00000000..a811e1d7
--- /dev/null
+++ b/cook-books/async-gateway/readme.txt
@@ -0,0 +1,28 @@
+However when you invoke a method you expect the method to return. And since gateway's method call represents a contract with the messaging system which states that for each request there will always be a reply you must always guarantee that your message flow is in compliance with such contract. And in a lot of cases you can based on how your flow is structured. But what about the cases where you can't (e.g, message was filtered out and discarded or routed into a unidirectional sub-flow)?
+With Spring Integration 2.0 we are introducing support for an Asynchronous Gateway which is
+a convenient way to initiate flows where you may not know if a reply is expected or how long will it take for it
+to arrive.
+A natural way to handle these types of scenarios in Java would be relying upon java.util.concurrent.Future
+instances, and that is exactly what Spring Integration uses to support an Asynchronous Gateway.
+
+This example demonstrates how you can apply Asynchronous Gateway based on the simple use case:
+
+We are sending request to a MathService to multiply random numbers by 2. As you can see from the configuration there is a filter that
+discards any request for the number that is less then a 100. This means that there will be no replies coming for the requests with
+numbers less then 100.
+Typically when using the regular Gateway the gateway method would lock until a timeout where here responses are coming back right away as Java Futures
+which we evaluate.
+
+To run this sample simply execute To run this sample simply execute org.springframework.integration.samples.async.gateway.AsyncGatewayTest
+
+You should see the following output:
+
+INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 107 by 2 is 214
+INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 146 by 2 is 292
+INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 189 by 2 is 378
+INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Result of multiplication of 130 by 2 is 260
+. . . . .
+INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 38 by 2 is can not be accomplished in 20 seconds
+INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 39 by 2 is can not be accomplished in 20 seconds
+INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 36 by 2 is can not be accomplished in 20 seconds
+INFO : org.springframework.integration.samples.async.gateway.AsyncGatewayTest - Multiplication of 37 by 2 is can not be accomplished in 20 seconds
diff --git a/cook-books/async-gateway/src/main/java/org/springframework/integration/samples/async/gateway/MathService.java b/cook-books/async-gateway/src/main/java/org/springframework/integration/samples/async/gateway/MathService.java
new file mode 100644
index 00000000..040da8a7
--- /dev/null
+++ b/cook-books/async-gateway/src/main/java/org/springframework/integration/samples/async/gateway/MathService.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2002-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.integration.samples.async.gateway;
+
+import java.util.Random;
+
+/**
+ * @author Oleg Zhurakousky
+ *
+ */
+public class MathService {
+ private final Random random = new Random();
+
+ public int multiplyByTwo(int i) throws Exception{
+ long sleep = random.nextInt(10) * 500;
+ Thread.sleep(sleep);
+ return i*2;
+ }
+}
diff --git a/cook-books/async-gateway/src/main/java/org/springframework/integration/samples/async/gateway/MathServiceGateway.java b/cook-books/async-gateway/src/main/java/org/springframework/integration/samples/async/gateway/MathServiceGateway.java
new file mode 100644
index 00000000..243dec18
--- /dev/null
+++ b/cook-books/async-gateway/src/main/java/org/springframework/integration/samples/async/gateway/MathServiceGateway.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2002-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.integration.samples.async.gateway;
+
+import java.util.concurrent.Future;
+
+/**
+ * @author Oleg Zhurakousky
+ *
+ */
+public interface MathServiceGateway {
+
+ Future multiplyByTwo(int i);
+}
diff --git a/cook-books/async-gateway/src/main/resources/META-INF/spring/integration/math-service-config.xml b/cook-books/async-gateway/src/main/resources/META-INF/spring/integration/math-service-config.xml
new file mode 100644
index 00000000..e56940ca
--- /dev/null
+++ b/cook-books/async-gateway/src/main/resources/META-INF/spring/integration/math-service-config.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cook-books/async-gateway/src/test/java/org/springframework/integration/samples/async/gateway/AsyncGatewayTest.java b/cook-books/async-gateway/src/test/java/org/springframework/integration/samples/async/gateway/AsyncGatewayTest.java
new file mode 100644
index 00000000..08edcbc6
--- /dev/null
+++ b/cook-books/async-gateway/src/test/java/org/springframework/integration/samples/async/gateway/AsyncGatewayTest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2002-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.integration.samples.async.gateway;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.log4j.Logger;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+/**
+ * @author Oleg Zhurakousky
+ *
+ */
+public class AsyncGatewayTest {
+ private static Logger logger = Logger.getLogger(AsyncGatewayTest.class);
+ private static ExecutorService executor = Executors.newFixedThreadPool(100);
+ private static int timeout = 20;
+
+ @Test
+ public void testAsyncGateway() throws Exception{
+ ApplicationContext ac = new FileSystemXmlApplicationContext("src/main/resources/META-INF/spring/integration/*.xml");
+ MathServiceGateway mathService = ac.getBean("mathService", MathServiceGateway.class);
+ Map> results = new HashMap>();
+ Random random = new Random();
+ for (int i = 0; i < 100; i++) {
+ int number = random.nextInt(200);
+ Future result = mathService.multiplyByTwo(number);
+ results.put(number, result);
+ }
+ for (final Map.Entry> resultEntry : results.entrySet()) {
+ executor.execute(new Runnable() {
+ public void run() {
+ int[] result = processFuture(resultEntry);
+
+ if (result[1] == -1){
+ logger.info("Multiplying " + result[0] + " should be easy. You should be able to multiply any number < 100 by 2 in your head");
+ } else if (result[1] == -2){
+ logger.info("Multiplication of " + result[0] + " by 2 is can not be accomplished in " + timeout + " seconds");
+ } else {
+ logger.info("Result of multiplication of " + result[0] + " by 2 is " + result[1]);
+ }
+ }
+ });
+ }
+ executor.shutdown();
+ executor.awaitTermination(60, TimeUnit.SECONDS);
+ logger.info("Finished");
+ }
+
+ public static int[] processFuture(Map.Entry> resultEntry){
+ int originalNumber = resultEntry.getKey();
+ Future result = resultEntry.getValue();
+ try {
+ int finalResult = result.get(timeout, TimeUnit.SECONDS);
+ return new int[]{originalNumber, finalResult};
+ } catch (ExecutionException e) {
+ return new int[]{originalNumber, -1};
+ } catch (TimeoutException tex){
+ return new int[]{originalNumber, -2};
+ } catch (Exception ex){
+ System.out.println();
+ // ignore
+ }
+ return null;
+ }
+}
diff --git a/cook-books/async-gateway/src/test/resources/log4j.xml b/cook-books/async-gateway/src/test/resources/log4j.xml
new file mode 100644
index 00000000..0b792903
--- /dev/null
+++ b/cook-books/async-gateway/src/test/resources/log4j.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cook-books/multipart-http/readme.txt b/cook-books/multipart-http/readme.txt
index 235eb5c4..39e6f313 100644
--- a/cook-books/multipart-http/readme.txt
+++ b/cook-books/multipart-http/readme.txt
@@ -1,3 +1,10 @@
+This sample demonstrates how you can send a multipart request to a Spring Integration's HTTP service using Spring's RestTemplate
+It consists of two parts - Client and Server.
+
+Client uses Spring's RestTemplate to assemble and send multipart request
+
+Server is Spring Integration's HTTP endpoint configuration.
+
To run this sample
1) deploy project
- If you are using STS and project is imported as Eclipse project in your workspace you can just execute 'Run on Server'
@@ -6,6 +13,6 @@ To run this sample
You should see the following output from the server:
- ### Successfully recieved multipart request ###
- company - SpringSource
- company-logo - as UploadedMultipartFile: spring09_logo.png
\ No newline at end of file
+INFO : ...MultipartClient - Successfully recieved multipart request: {company=[[Ljava.lang.String;@147e8bd9], company-logo=[org.springframework.integration.http.UploadedMultipartFile@f5e12]}
+INFO : ...MultipartClient - company - SpringSource
+INFO : org.springframework.integration.samples.multipart.MultipartClient - company-logo - as UploadedMultipartFile: spring09_logo.png