From 3820fd225b31d1d8a97d4dd2de53d1c61cabe8de Mon Sep 17 00:00:00 2001 From: markpollack Date: Thu, 15 Jul 2010 17:49:37 -0400 Subject: [PATCH] add declareQueue to AmqpAdmin interface additiona docs XML example to configure AmqpAdmin implementations --- helloworld/.springBeans | 3 ++- .../BrokerConfigurationApplication.java | 22 +++++++++++++++++++ .../main/resources/rabbitConfiguration.xml | 16 ++++++++++++++ .../client/RabbitClientConfiguration.java | 14 +++++------- 4 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 helloworld/src/main/java/org/springframework/amqp/helloworld/BrokerConfigurationApplication.java create mode 100644 helloworld/src/main/resources/rabbitConfiguration.xml diff --git a/helloworld/.springBeans b/helloworld/.springBeans index 0c014a9..5d96b7c 100644 --- a/helloworld/.springBeans +++ b/helloworld/.springBeans @@ -1,12 +1,13 @@ 1 - + + src/main/resources/rabbitConfiguration.xml diff --git a/helloworld/src/main/java/org/springframework/amqp/helloworld/BrokerConfigurationApplication.java b/helloworld/src/main/java/org/springframework/amqp/helloworld/BrokerConfigurationApplication.java new file mode 100644 index 0000000..b4bb07c --- /dev/null +++ b/helloworld/src/main/java/org/springframework/amqp/helloworld/BrokerConfigurationApplication.java @@ -0,0 +1,22 @@ +package org.springframework.amqp.helloworld; + +import org.springframework.amqp.core.AmqpAdmin; +import org.springframework.amqp.core.Queue; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class BrokerConfigurationApplication { + + /** + * An example application that only configures the AMQP broker + */ + public static void main(String[] args) { + ApplicationContext context = new ClassPathXmlApplicationContext("rabbitConfiguration.xml"); + AmqpAdmin amqpAdmin = context.getBean(AmqpAdmin.class); + Queue helloWorldQueue = new Queue("hello.world.queue"); + + amqpAdmin.declareQueue(helloWorldQueue); + + } + +} diff --git a/helloworld/src/main/resources/rabbitConfiguration.xml b/helloworld/src/main/resources/rabbitConfiguration.xml new file mode 100644 index 0000000..36a673c --- /dev/null +++ b/helloworld/src/main/resources/rabbitConfiguration.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/client/RabbitClientConfiguration.java b/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/client/RabbitClientConfiguration.java index 94596f8..6186598 100644 --- a/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/client/RabbitClientConfiguration.java +++ b/stocks/src/main/java/org/springframework/amqp/rabbit/stocks/config/client/RabbitClientConfiguration.java @@ -18,6 +18,7 @@ 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; @@ -92,7 +93,7 @@ public class RabbitClientConfiguration extends AbstractStockAppRabbitConfigurati // Broker Configuration -// @PostConstruct +// @PostContruct // public void declareClientBrokerConfiguration() { // declare(marketDataQueue); // declare(new Binding(marketDataQueue, MARKET_DATA_EXCHANGE, marketDataRoutingKey)); @@ -104,7 +105,7 @@ public class RabbitClientConfiguration extends AbstractStockAppRabbitConfigurati @Bean public Queue marketDataQueue() { - return generatedQueue(); + return amqpAdmin().declareQueue(); } /** @@ -112,11 +113,8 @@ public class RabbitClientConfiguration extends AbstractStockAppRabbitConfigurati * @return */ @Bean - public Binding marketDataBinding() { - return new Binding(marketDataQueue(), marketDataExchange(), marketDataRoutingKey); - - // Using BindingBuilder - //return declareBinding(from(marketDataQueue()).to(marketDataExchange()).with(marketDataRoutingKey)); + public Binding marketDataBinding() { + return BindingBuilder.from(marketDataQueue()).to(marketDataExchange()).with(marketDataRoutingKey); } /** @@ -124,7 +122,7 @@ public class RabbitClientConfiguration extends AbstractStockAppRabbitConfigurati */ @Bean public Queue traderJoeQueue() { - return generatedQueue(); + return amqpAdmin().declareQueue(); } }