From dcd0a42290eea408a920fc76d2be7cf68d92c920 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 13 Jun 2012 00:10:39 +0300 Subject: [PATCH] How to implement Scatter-Gather --- .../ScatterGatherTests-context.xml | 54 ++++++++++++++++ .../scattergather/ScatterGatherTests.java | 61 +++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 spring-integration-core/src/test/java/org/springframework/integration/scattergather/ScatterGatherTests-context.xml create mode 100644 spring-integration-core/src/test/java/org/springframework/integration/scattergather/ScatterGatherTests.java diff --git a/spring-integration-core/src/test/java/org/springframework/integration/scattergather/ScatterGatherTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/scattergather/ScatterGatherTests-context.xml new file mode 100644 index 00000000000..c67731d2688 --- /dev/null +++ b/spring-integration-core/src/test/java/org/springframework/integration/scattergather/ScatterGatherTests-context.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/scattergather/ScatterGatherTests.java b/spring-integration-core/src/test/java/org/springframework/integration/scattergather/ScatterGatherTests.java new file mode 100644 index 00000000000..80ab8d2b1dd --- /dev/null +++ b/spring-integration-core/src/test/java/org/springframework/integration/scattergather/ScatterGatherTests.java @@ -0,0 +1,61 @@ +/* + * Copyright 2002-2012 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.scattergather; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.integration.Message; +import org.springframework.integration.MessageChannel; +import org.springframework.integration.core.PollableChannel; +import org.springframework.integration.support.MessageBuilder; +import org.springframework.test.annotation.Repeat; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * @author Artem Bilan + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration +public class ScatterGatherTests { + + @Autowired + private MessageChannel inputAuctionChannel; + + @Autowired + private MessageChannel inputDistributionChannel; + + @Autowired + private PollableChannel output; + + @Test + @Repeat(10) + public void testAuction() throws Exception { + Message quoteMessage = MessageBuilder.withPayload("testQuote").build(); + inputAuctionChannel.send(quoteMessage); + Message bestQuoteMessage = output.receive(); + System.out.println(bestQuoteMessage); + } + + @Test + @Repeat(10) + public void testDistribution() throws Exception { + Message quoteMessage = MessageBuilder.withPayload("testQuote").build(); + inputDistributionChannel.send(quoteMessage); + Message bestQuoteMessage = output.receive(); + System.out.println(bestQuoteMessage); + } + +}