add declareQueue to AmqpAdmin interface
additiona docs XML example to configure AmqpAdmin implementations
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beansProjectDescription>
|
||||
<version>1</version>
|
||||
<pluginVersion><![CDATA[2.2.7.200909012107-CI-R3397-B453]]></pluginVersion>
|
||||
<pluginVersion><![CDATA[2.3.3.201005160334-M1]]></pluginVersion>
|
||||
<configSuffixes>
|
||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||
</configSuffixes>
|
||||
<enableImports><![CDATA[true]]></enableImports>
|
||||
<configs>
|
||||
<config>src/main/resources/rabbitConfiguration.xml</config>
|
||||
</configs>
|
||||
<configSets>
|
||||
<configSet>
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
16
helloworld/src/main/resources/rabbitConfiguration.xml
Normal file
16
helloworld/src/main/resources/rabbitConfiguration.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
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-3.0.xsd">
|
||||
|
||||
<bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection.SingleConnectionFactory">
|
||||
<constructor-arg value="localhost"/>
|
||||
<property name="username" value="guest"/>
|
||||
<property name="password" value="guest"/>
|
||||
</bean>
|
||||
|
||||
<bean id="amqpAdmin" class="org.springframework.amqp.rabbit.core.RabbitAdmin">
|
||||
<constructor-arg ref="connectionFactory"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user