The abstract method configureRabbitTemplate lets the Client and Server further customize
- * the rabbit template to their specific needs.
- *
- * @author Mark Pollack
- * @author Mark Fisher
- */
-@Configuration
-public abstract class AbstractStockAppRabbitConfiguration extends AbstractRabbitConfiguration {
-
- /**
- * Shared topic exchange used for publishing any market data (e.g. stock quotes)
- */
- protected static String MARKET_DATA_EXCHANGE_NAME = "app.stock.marketdata";
-
- /**
- * The server-side consumer's queue that provides point-to-point semantics for stock requests.
- */
- protected static String STOCK_REQUEST_QUEUE_NAME = "app.stock.request";
-
- /**
- * Key that clients will use to send to the stock request queue via the default direct exchange.
- */
- protected static String STOCK_REQUEST_ROUTING_KEY = STOCK_REQUEST_QUEUE_NAME;
-
-
- protected abstract void configureRabbitTemplate(RabbitTemplate template);
-
- @Bean
- public ConnectionFactory connectionFactory() {
- //TODO make it possible to customize in subclasses.
- SingleConnectionFactory connectionFactory = new SingleConnectionFactory("localhost");
- connectionFactory.setUsername("guest");
- connectionFactory.setPassword("guest");
- return connectionFactory;
- }
-
- @Bean
- public RabbitTemplate rabbitTemplate() {
- RabbitTemplate template = new RabbitTemplate(connectionFactory());
- template.setMessageConverter(jsonMessageConverter());
- configureRabbitTemplate(template);
- return template;
- }
-
- @Bean
- public MessageConverter jsonMessageConverter() {
- return new JsonMessageConverter();
- }
-
- @Bean
- public TopicExchange marketDataExchange() {
- return new TopicExchange(MARKET_DATA_EXCHANGE_NAME);
- }
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/RoutingKey.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/RoutingKey.java
deleted file mode 100644
index 2623aa7a..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/RoutingKey.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.config;
-
-/**
- * Enumerations for the RoutingKeys used in the application to allow for a more fluent API
- * style when configuring the broker in code.
- *
- * @author Mark Pollack
- */
-public enum RoutingKey {
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/client/RabbitClientConfiguration.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/client/RabbitClientConfiguration.java
deleted file mode 100644
index 0d73576f..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/client/RabbitClientConfiguration.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.config.client;
-
-
-import org.springframework.amqp.core.Binding;
-import org.springframework.amqp.core.BindingBuilder;
-import org.springframework.amqp.core.Queue;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
-import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter;
-import org.springframework.amqp.rabbit.stocks.config.AbstractStockAppRabbitConfiguration;
-import org.springframework.amqp.rabbit.stocks.gateway.RabbitStockServiceGateway;
-import org.springframework.amqp.rabbit.stocks.gateway.StockServiceGateway;
-import org.springframework.amqp.rabbit.stocks.handler.ClientHandler;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * Configures RabbitTemplate and creates the Trader queue and binding for the client.
- *
- * @author Mark Pollack
- * @author Mark Fisher
- */
-@Configuration
-public class RabbitClientConfiguration extends AbstractStockAppRabbitConfiguration {
-
- @Value("${stocks.quote.pattern}")
- private String marketDataRoutingKey;
-
- @Autowired
- private ClientHandler clientHandler;
-
-
- // Create the Queue definitions that write up the Message listener container
-
- //private Queue marketDataQueue = new UniquelyNamedQueue("mktdata");
-
- //private Queue traderJoeQueue = new UniquelyNamedQueue("joe");
-
- /**
- * The client's template will by default send to the exchange defined
- * in {@link org.springframework.amqp.rabbit.config.AbstractRabbitConfiguration#rabbitTemplate()}
- * with the routing key {@link AbstractStockAppRabbitConfiguration#STOCK_REQUEST_QUEUE_NAME}
- *
- * The default exchange will delivery to a queue whose name matches the routing key value.
- */
- @Override
- public void configureRabbitTemplate(RabbitTemplate rabbitTemplate) {
- rabbitTemplate.setRoutingKey(STOCK_REQUEST_QUEUE_NAME);
- }
-
- @Bean
- public StockServiceGateway stockServiceGateway() {
- RabbitStockServiceGateway gateway = new RabbitStockServiceGateway();
- gateway.setRabbitTemplate(rabbitTemplate());
- gateway.setDefaultReplyToQueue(traderJoeQueue());
- return gateway;
- }
-
- @Bean
- public SimpleMessageListenerContainer messageListenerContainer() {
- SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory());
- container.setQueues(marketDataQueue(), traderJoeQueue());
- container.setMessageListener(messageListenerAdapter());
- return container;
-
- //container(using(connectionFactory()).listenToQueues(marketDataQueue(), traderJoeQueue()).withListener(messageListenerAdapter()).
- }
-
- @Bean
- public MessageListenerAdapter messageListenerAdapter() {
- return new MessageListenerAdapter(clientHandler, jsonMessageConverter());
- }
-
-
- // Broker Configuration
-
-// @PostContruct
-// public void declareClientBrokerConfiguration() {
-// declare(marketDataQueue);
-// declare(new Binding(marketDataQueue, MARKET_DATA_EXCHANGE, marketDataRoutingKey));
-// declare(traderJoeQueue);
-// // no need to bind traderJoeQueue as it is automatically bound to the default direct exchanage, which is what we will use
-//
-// //add as many declare statements as needed like a script.
-// }
-
- @Bean
- public Queue marketDataQueue() {
- return amqpAdmin().declareQueue();
- }
-
- /**
- * Binds to the market data exchange. Interested in any stock quotes.
- */
- @Bean
- public Binding marketDataBinding() {
- return BindingBuilder.from(marketDataQueue()).to(marketDataExchange()).with(marketDataRoutingKey);
- }
-
- /**
- * This queue does not need a binding, since it relies on the default exchange.
- */
- @Bean
- public Queue traderJoeQueue() {
- return amqpAdmin().declareQueue();
- }
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/server/RabbitServerConfiguration.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/server/RabbitServerConfiguration.java
deleted file mode 100644
index 6201ce19..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/server/RabbitServerConfiguration.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.config.server;
-
-import org.springframework.amqp.core.Queue;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.amqp.rabbit.stocks.config.AbstractStockAppRabbitConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * Configures RabbitTemplate for the server.
- *
- * @author Mark Pollack
- * @author Mark Fisher
- */
-@Configuration
-public class RabbitServerConfiguration extends AbstractStockAppRabbitConfiguration {
-
- /**
- * The server's template will by default send to the topic exchange named
- * {@link AbstractStockAppRabbitConfiguration#MARKET_DATA_EXCHANGE_NAME}.
- */
- public void configureRabbitTemplate(RabbitTemplate rabbitTemplate) {
- rabbitTemplate.setExchange(MARKET_DATA_EXCHANGE_NAME);
- }
-
- /**
- * We don't need to define any binding for the stock request queue, since it's relying
- * on the default (no-name) direct exchange to which every queue is implicitly bound.
- */
- @Bean
- public Queue stockRequestQueue() {
- return new Queue(STOCK_REQUEST_QUEUE_NAME);
- }
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/Quote.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/Quote.java
deleted file mode 100644
index 96efabce..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/Quote.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.domain;
-
-/**
- * Domain object representing a stock quote.
- *
- * @author Mark Fisher
- */
-public class Quote {
-
- private Stock stock;
- private String price;
-
- public Quote() {
- }
-
- public Quote(Stock stock, String price) {
- this.stock = stock;
- this.price = price;
- }
-
- public Stock getStock() {
- return this.stock;
- }
-
- public void setStock(Stock stock) {
- this.stock = stock;
- }
-
- public String getPrice() {
- return price;
- }
-
- public void setPrice(String price) {
- this.price = price;
- }
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/Stock.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/Stock.java
deleted file mode 100644
index ac7faac9..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/Stock.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.domain;
-
-/**
- * @author Mark Fisher
- */
-public class Stock {
-
- private String ticker;
-
- private StockExchange stockExchange;
-
- public String getTicker() {
- return ticker;
- }
-
- public void setTicker(String ticker) {
- this.ticker = ticker;
- }
-
- public StockExchange getStockExchange() {
- return stockExchange;
- }
-
- public void setStockExchange(StockExchange stockExchange) {
- this.stockExchange = stockExchange;
- }
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/StockExchange.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/StockExchange.java
deleted file mode 100644
index d7bfc6e2..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/StockExchange.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.domain;
-
-/**
- * Enumeration for Stock Exchanges.
- *
- * @author Mark Fisher
- */
-public enum StockExchange {
-
- nyse, nasdaq;
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/TradeRequest.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/TradeRequest.java
deleted file mode 100644
index 7bac7e33..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/TradeRequest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.domain;
-
-import java.math.BigDecimal;
-
-/**
- * Simple trade request 'data' object. No functionality in this 'domain' class.
- * @author Mark Pollack
- *
- */
-public class TradeRequest {
-
- private String ticker;
-
- private long quantity;
-
- private BigDecimal price;
-
- private String orderType;
-
- private String accountName;
-
- private boolean buyRequest;
-
- private String userName;
-
- private String requestId;
-
- public String getTicker() {
- return ticker;
- }
-
- public void setTicker(String ticker) {
- this.ticker = ticker;
- }
-
- public long getQuantity() {
- return quantity;
- }
-
- public void setQuantity(long quantity) {
- this.quantity = quantity;
- }
-
- public BigDecimal getPrice() {
- return price;
- }
-
- public void setPrice(BigDecimal price) {
- this.price = price;
- }
-
- public String getOrderType() {
- return orderType;
- }
-
- public void setOrderType(String orderType) {
- this.orderType = orderType;
- }
-
- public String getAccountName() {
- return accountName;
- }
-
- public void setAccountName(String accountName) {
- this.accountName = accountName;
- }
-
- public boolean isBuyRequest() {
- return buyRequest;
- }
-
- public void setBuyRequest(boolean buyRequest) {
- this.buyRequest = buyRequest;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getRequestId() {
- return requestId;
- }
-
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
-
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/TradeResponse.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/TradeResponse.java
deleted file mode 100644
index 8770a7fb..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/domain/TradeResponse.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.domain;
-
-import java.math.BigDecimal;
-
-/**
- * Simple trade request 'data' object. No functionality in this 'domain' class.
- * @author Mark Pollack
- *
- */
-public class TradeResponse {
-
- private String ticker;
-
- private long quantity;
-
- private BigDecimal price;
-
- private String orderType;
-
- private String confirmationNumber;
-
- private boolean error;
-
- private String errorMessage;
-
- public String getTicker() {
- return ticker;
- }
-
- public void setTicker(String ticker) {
- this.ticker = ticker;
- }
-
- public long getQuantity() {
- return quantity;
- }
-
- public void setQuantity(long quantity) {
- this.quantity = quantity;
- }
-
- public BigDecimal getPrice() {
- return price;
- }
-
- public void setPrice(BigDecimal price) {
- this.price = price;
- }
-
- public String getOrderType() {
- return orderType;
- }
-
- public void setOrderType(String orderType) {
- this.orderType = orderType;
- }
-
- public String getConfirmationNumber() {
- return confirmationNumber;
- }
-
- public void setConfirmationNumber(String confirmationNumber) {
- this.confirmationNumber = confirmationNumber;
- }
-
- public boolean isError() {
- return error;
- }
-
- public void setError(boolean error) {
- this.error = error;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
- @Override
- public String toString() {
- return "TradeResponse [confirmationNumber=" + confirmationNumber
- + ", error=" + error + ", errorMessage=" + errorMessage
- + ", orderType=" + orderType + ", price=" + price
- + ", quantity=" + quantity + ", ticker=" + ticker + "]";
- }
-
-
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/MarketDataGateway.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/MarketDataGateway.java
deleted file mode 100644
index 2ee93d4c..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/MarketDataGateway.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.gateway;
-
-/**
- * Gateway interface for sending market data to clients
- * @author Mark Pollack
- *
- */
-public interface MarketDataGateway {
-
- void sendMarketData();
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/RabbitMarketDataGateway.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/RabbitMarketDataGateway.java
deleted file mode 100644
index 32991054..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/RabbitMarketDataGateway.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.gateway;
-
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.amqp.rabbit.core.support.RabbitGatewaySupport;
-import org.springframework.amqp.rabbit.stocks.domain.Quote;
-import org.springframework.amqp.rabbit.stocks.domain.Stock;
-import org.springframework.amqp.rabbit.stocks.domain.StockExchange;
-
-/**
- * Rabbit implementation of the {@link MarketDataGateway} for sending Market data.
- *
- * @author Mark Pollack
- * @author Mark Fisher
- */
-public class RabbitMarketDataGateway extends RabbitGatewaySupport implements MarketDataGateway {
-
- private static Log logger = LogFactory.getLog(RabbitMarketDataGateway.class);
-
- private static final Random random = new Random();
-
- private final List stocks = new ArrayList();
-
-
- public RabbitMarketDataGateway() {
- this.stocks.add(new MockStock("AAPL", StockExchange.nasdaq, 255));
- this.stocks.add(new MockStock("CSCO", StockExchange.nasdaq, 22));
- this.stocks.add(new MockStock("DELL", StockExchange.nasdaq, 15));
- this.stocks.add(new MockStock("GOOG", StockExchange.nasdaq, 500));
- this.stocks.add(new MockStock("INTC", StockExchange.nasdaq, 22));
- this.stocks.add(new MockStock("MSFT", StockExchange.nasdaq, 29));
- this.stocks.add(new MockStock("ORCL", StockExchange.nasdaq, 24));
- this.stocks.add(new MockStock("CAJ", StockExchange.nyse, 43));
- this.stocks.add(new MockStock("F", StockExchange.nyse, 12));
- this.stocks.add(new MockStock("GE", StockExchange.nyse, 18));
- this.stocks.add(new MockStock("HMC", StockExchange.nyse, 32));
- this.stocks.add(new MockStock("HPQ", StockExchange.nyse, 48));
- this.stocks.add(new MockStock("IBM", StockExchange.nyse, 130));
- this.stocks.add(new MockStock("TM", StockExchange.nyse, 76));
- }
-
-
- public void sendMarketData() {
- Quote quote = generateFakeQuote();
- Stock stock = quote.getStock();
- logger.info("Sending Market Data for " + stock.getTicker());
- String routingKey = "app.stock.quotes."+ stock.getStockExchange() + "." + stock.getTicker();
- getRabbitTemplate().convertAndSend(routingKey, quote);
- }
-
- private Quote generateFakeQuote() {
- MockStock stock = this.stocks.get(random.nextInt(this.stocks.size()));
- String price = stock.randomPrice();
- return new Quote(stock, price);
- }
-
-
- private static class MockStock extends Stock {
-
- private final int basePrice;
- private final DecimalFormat twoPlacesFormat = new DecimalFormat("0.00");
-
- private MockStock(String ticker, StockExchange stockExchange, int basePrice) {
- this.setTicker(ticker);
- this.setStockExchange(stockExchange);
- this.basePrice = basePrice;
- }
-
- private String randomPrice() {
- return this.twoPlacesFormat.format(this.basePrice + Math.abs(random.nextGaussian()));
- }
- }
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/RabbitStockServiceGateway.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/RabbitStockServiceGateway.java
deleted file mode 100644
index 6ac673a0..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/RabbitStockServiceGateway.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.gateway;
-
-import java.io.UnsupportedEncodingException;
-import java.util.UUID;
-
-import org.springframework.amqp.AmqpException;
-import org.springframework.amqp.core.Address;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.core.MessagePostProcessor;
-import org.springframework.amqp.core.Queue;
-import org.springframework.amqp.rabbit.core.support.RabbitGatewaySupport;
-import org.springframework.amqp.rabbit.stocks.domain.TradeRequest;
-
-/**
- * Rabbit implementation of {@link StockServiceGateway} to send trade requests to an external process.
- *
- * @author Mark Pollack
- */
-public class RabbitStockServiceGateway extends RabbitGatewaySupport implements StockServiceGateway {
-
- private String defaultReplyToQueue;
-
- public void setDefaultReplyToQueue(String defaultReplyToQueue) {
- this.defaultReplyToQueue = defaultReplyToQueue;
- }
-
- public void setDefaultReplyToQueue(Queue defaultReplyToQueue) {
- this.defaultReplyToQueue = defaultReplyToQueue.getName();
- }
-
- public void send(TradeRequest tradeRequest) {
- getRabbitTemplate().convertAndSend(tradeRequest, new MessagePostProcessor() {
- public Message postProcessMessage(Message message) throws AmqpException {
- message.getMessageProperties().setReplyTo(new Address(defaultReplyToQueue));
- try {
- message.getMessageProperties().setCorrelationId(UUID.randomUUID().toString().getBytes("UTF-8"));
- }
- catch (UnsupportedEncodingException e) {
- throw new AmqpException(e);
- }
- return message;
- }
- });
- }
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/StockServiceGateway.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/StockServiceGateway.java
deleted file mode 100644
index fa252034..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/gateway/StockServiceGateway.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.gateway;
-
-import org.springframework.amqp.rabbit.stocks.domain.TradeRequest;
-
-/**
- * Gateway interface that sends trades to an external process.
- *
- * @author Mark Pollack
- */
-public interface StockServiceGateway {
-
- void send(TradeRequest tradeRequest);
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/handler/ClientHandler.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/handler/ClientHandler.java
deleted file mode 100644
index e7138e70..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/handler/ClientHandler.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.handler;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.springframework.amqp.rabbit.stocks.domain.Quote;
-import org.springframework.amqp.rabbit.stocks.domain.Stock;
-import org.springframework.amqp.rabbit.stocks.domain.TradeResponse;
-import org.springframework.amqp.rabbit.stocks.ui.StockController;
-
-/**
- * POJO handler that receives market data and trade responses. Calls are delegated to the UI controller.
- *
- * @author Mark Pollack
- * @author Mark Fisher
- */
-public class ClientHandler {
-
- private static Log log = LogFactory.getLog(ClientHandler.class);
-
- private StockController stockController;
-
- public StockController getStockController() {
- return stockController;
- }
-
- public void setStockController(StockController stockController) {
- this.stockController = stockController;
- }
-
- public void handleMessage(Quote quote) {
- Stock stock = quote.getStock();
- log.info("Received market data. Ticker = " + stock.getTicker() + ", Price = " + quote.getPrice());
- stockController.displayQuote(quote);
- }
-
- public void handleMessage(TradeResponse tradeResponse) {
- log.info("Received trade repsonse. [" + tradeResponse + "]");
- stockController.UpdateTrade(tradeResponse);
- }
-
-}
diff --git a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/handler/ServerHandler.java b/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/handler/ServerHandler.java
deleted file mode 100644
index 2f965e13..00000000
--- a/spring-amqp-samples/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/handler/ServerHandler.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.amqp.rabbit.stocks.handler;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.amqp.rabbit.stocks.domain.TradeRequest;
-import org.springframework.amqp.rabbit.stocks.domain.TradeResponse;
-import org.springframework.amqp.rabbit.stocks.service.CreditCheckService;
-import org.springframework.amqp.rabbit.stocks.service.ExecutionVenueService;
-import org.springframework.amqp.rabbit.stocks.service.TradingService;
-import org.springframework.util.StringUtils;
-
-
-/**
- * POJO handler that receives trade requests and sends back a trade response. Main application
- * logic sits here which coordinates between {@link ExecutionVenueService}, {@link CreditCheckService},
- * and {@link TradingService}.
- *
- * @author Mark Pollack
- *
- */
-public class ServerHandler {
-
- private ExecutionVenueService executionVenueService;
-
- private CreditCheckService creditCheckService;
-
- private TradingService tradingService;
-
-
-
- public ServerHandler(ExecutionVenueService executionVenueService,
- CreditCheckService creditCheckService,
- TradingService tradingService) {
- this.executionVenueService = executionVenueService;
- this.creditCheckService = creditCheckService;
- this.tradingService = tradingService;
- }
-
- public TradeResponse handleMessage(TradeRequest tradeRequest)
- {
- TradeResponse tradeResponse;
- List> errors = new ArrayList