diff --git a/spring-integration-samples/async-gateway/.classpath b/spring-integration-samples/async-gateway/.classpath
new file mode 100644
index 0000000000..96489ff1c9
--- /dev/null
+++ b/spring-integration-samples/async-gateway/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-samples/async-gateway/.project b/spring-integration-samples/async-gateway/.project
new file mode 100644
index 0000000000..3897200b11
--- /dev/null
+++ b/spring-integration-samples/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/spring-integration-samples/async-gateway/.settings/org.maven.ide.eclipse.prefs b/spring-integration-samples/async-gateway/.settings/org.maven.ide.eclipse.prefs
new file mode 100644
index 0000000000..28947cd0d9
--- /dev/null
+++ b/spring-integration-samples/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/spring-integration-samples/async-gateway/.settings/org.springframework.ide.eclipse.core.prefs b/spring-integration-samples/async-gateway/.settings/org.springframework.ide.eclipse.core.prefs
new file mode 100644
index 0000000000..ed4b87950f
--- /dev/null
+++ b/spring-integration-samples/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/spring-integration-samples/async-gateway/pom.xml b/spring-integration-samples/async-gateway/pom.xml
new file mode 100644
index 0000000000..d329bb46a6
--- /dev/null
+++ b/spring-integration-samples/async-gateway/pom.xml
@@ -0,0 +1,19 @@
+
+ 4.0.0
+
+ org.springframework.integration.samples
+ spring-integration-samples
+ 2.0.0.BUILD-SNAPSHOT
+
+ async-gateway
+ Gateway Demo
+ jar
+
+
+ org.springframework.integration
+ spring-integration-core
+ 2.0.0.BUILD-SNAPSHOT
+
+
+
\ No newline at end of file
diff --git a/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/DemoClient.java b/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/DemoClient.java
new file mode 100644
index 0000000000..6ea6001ab9
--- /dev/null
+++ b/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/DemoClient.java
@@ -0,0 +1,85 @@
+/*
+ * 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.gateway.futures;
+
+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.springframework.context.ApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+
+/**
+ * @author Oleg Zhurakousky
+ *
+ */
+public class DemoClient {
+
+ private static ExecutorService executor = Executors.newFixedThreadPool(100);
+ private static int timeout = 20;
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ 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){
+ System.out.println("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){
+ System.out.println("Multiplication of " + result[0] + " by 2 is can not be accomplished in " + timeout + " seconds");
+ } else {
+ System.out.println("Result of multiplication of " + result[0] + " by 2 is " + result[1]);
+ }
+ }
+ });
+ }
+ }
+
+ 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/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/ExceptionMapper.java b/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/ExceptionMapper.java
new file mode 100644
index 0000000000..e0b22234d8
--- /dev/null
+++ b/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/ExceptionMapper.java
@@ -0,0 +1,34 @@
+/*
+ * 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.gateway.futures;
+
+import org.springframework.integration.Message;
+import org.springframework.integration.MessageHandlingException;
+import org.springframework.integration.mapping.InboundMessageMapper;
+
+/**
+ * @author Oleg Zhurakousky
+ *
+ */
+public class ExceptionMapper implements InboundMessageMapper{
+
+ @Override
+ public Message> toMessage(MessageHandlingException messageHandlingException)
+ throws Exception {
+ return messageHandlingException.getFailedMessage();
+ }
+
+}
diff --git a/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/MathService.java b/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/MathService.java
new file mode 100644
index 0000000000..d5aecc3431
--- /dev/null
+++ b/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/MathService.java
@@ -0,0 +1,33 @@
+/*
+ * 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.gateway.futures;
+
+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) * 1000;
+ Thread.sleep(sleep);
+ //System.out.println("Multiplied " + i);
+ return i*2;
+ }
+}
diff --git a/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/MathServiceGateway.java b/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/MathServiceGateway.java
new file mode 100644
index 0000000000..9d659a9e61
--- /dev/null
+++ b/spring-integration-samples/async-gateway/src/main/java/org/springframework/integration/samples/gateway/futures/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.gateway.futures;
+
+import java.util.concurrent.Future;
+
+/**
+ * @author Oleg Zhurakousky
+ *
+ */
+public interface MathServiceGateway {
+
+ Future multiplyByTwo(int i);
+}
diff --git a/spring-integration-samples/async-gateway/src/main/resources/META-INF/spring/integration/math-service-config.xml b/spring-integration-samples/async-gateway/src/main/resources/META-INF/spring/integration/math-service-config.xml
new file mode 100644
index 0000000000..1299060f65
--- /dev/null
+++ b/spring-integration-samples/async-gateway/src/main/resources/META-INF/spring/integration/math-service-config.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+