本文整理汇总了Java中org.springframework.amqp.rabbit.core.RabbitAdmin.declareExchange方法的典型用法代码示例。如果您正苦于以下问题:Java RabbitAdmin.declareExchange方法的具体用法?Java RabbitAdmin.declareExchange怎么用?Java RabbitAdmin.declareExchange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.amqp.rabbit.core.RabbitAdmin
的用法示例。
在下文中一共展示了RabbitAdmin.declareExchange方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkRabbitMQAMQPProtocol
import org.springframework.amqp.rabbit.core.RabbitAdmin; //导入方法依赖的package包/类
public String checkRabbitMQAMQPProtocol(String messageAsString,
String url,
String user,
String password,
String vhost) throws Exception {
org.springframework.amqp.rabbit.connection.CachingConnectionFactory cf =
new org.springframework.amqp.rabbit.connection.CachingConnectionFactory();
URL formattedUrl = new URL("http://" + url);
cf.setHost(formattedUrl.getHost());
cf.setPort(formattedUrl.getPort());
cf.setUsername(user);
cf.setPassword(password);
cf.setVirtualHost(vhost);
RabbitAdmin admin = new RabbitAdmin(cf);
org.springframework.amqp.core.Queue queue = new org.springframework.amqp.core.Queue("myQueue");
admin.declareQueue(queue);
TopicExchange exchange = new TopicExchange("myExchange");
admin.declareExchange(exchange);
admin.declareBinding(
BindingBuilder.bind(queue).to(exchange).with("foo.*"));
RabbitTemplate template = new RabbitTemplate(cf);
template.convertAndSend("myExchange", "foo.bar", messageAsString);
String receivedMessage = template.receiveAndConvert("myQueue").toString();
return receivedMessage;
}
示例2: init
import org.springframework.amqp.rabbit.core.RabbitAdmin; //导入方法依赖的package包/类
@PostConstruct
private void init() {
log.info("Initialization of RabbitConfiguration");
emsConnectionFactory = new CachingConnectionFactory();
((CachingConnectionFactory) emsConnectionFactory).setHost(brokerIp);
((CachingConnectionFactory) emsConnectionFactory).setPort(rabbitPort);
((CachingConnectionFactory) emsConnectionFactory).setUsername(emsRabbitUsername);
((CachingConnectionFactory) emsConnectionFactory).setPassword(emsRabbitPassword);
rabbitAdmin = new RabbitAdmin(emsConnectionFactory);
TopicExchange topicExchange = new TopicExchange("openbaton-exchange");
rabbitAdmin.declareExchange(topicExchange);
log.info("exchange declared");
queueName_emsRegistrator = "ems." + vnfmHelper.getVnfmEndpoint() + ".register";
rabbitAdmin.declareQueue(new Queue(queueName_emsRegistrator, durable, exclusive, autodelete));
}
示例3: declareExchange
import org.springframework.amqp.rabbit.core.RabbitAdmin; //导入方法依赖的package包/类
@Test
public void declareExchange() throws Exception {
RabbitAdmin bean = (RabbitAdmin) applicationContext
.getBean("rabbitAdmin");
//
String EXCHANGE_NAME = "TEST_EXCHANGE";
TopicExchange exchange = new TopicExchange(EXCHANGE_NAME);
bean.declareExchange(exchange);
//
String QUEUE_NAME = "TEST_EXCHANGE";
Queue queue = new Queue(QUEUE_NAME, false);
bean.declareQueue(queue);
//
// binding
Binding binding = BindingBuilder.bind(queue).to(exchange)
.with(QUEUE_NAME);
System.out.println(binding);
}
示例4: rabbitAdmin
import org.springframework.amqp.rabbit.core.RabbitAdmin; //导入方法依赖的package包/类
@Bean
@Required
RabbitAdmin rabbitAdmin(String uniqueQueueName) {
RabbitAdmin admin = new RabbitAdmin(connectionFactory());
admin.setAutoStartup(true);
admin.declareExchange(eventBusExchange());
admin.declareQueue(eventStream(uniqueQueueName));
admin.declareBinding(binding(uniqueQueueName));
return admin;
}
示例5: rabbitAdmin
import org.springframework.amqp.rabbit.core.RabbitAdmin; //导入方法依赖的package包/类
@Bean
@Required
RabbitAdmin rabbitAdmin() {
RabbitAdmin admin = new RabbitAdmin(connectionFactory());
admin.setAutoStartup(true);
admin.declareExchange(eventBusExchange());
admin.declareQueue(defaultStream());
admin.declareBinding(binding());
return admin;
}
示例6: testConsumerPropertiesWithUserInfrastructureNoBind
import org.springframework.amqp.rabbit.core.RabbitAdmin; //导入方法依赖的package包/类
@Test
public void testConsumerPropertiesWithUserInfrastructureNoBind() throws Exception {
RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource());
Queue queue = new Queue("propsUser1.infra");
admin.declareQueue(queue);
DirectExchange exchange = new DirectExchange("propsUser1");
admin.declareExchange(exchange);
admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("foo"));
RabbitTestBinder binder = getBinder();
ExtendedConsumerProperties<RabbitConsumerProperties> properties = createConsumerProperties();
properties.getExtension().setDeclareExchange(false);
properties.getExtension().setBindQueue(false);
Binding<MessageChannel> consumerBinding = binder.bindConsumer("propsUser1", "infra",
createBindableChannel("input", new BindingProperties()), properties);
Lifecycle endpoint = extractEndpoint(consumerBinding);
SimpleMessageListenerContainer container = TestUtils.getPropertyValue(endpoint, "messageListenerContainer",
SimpleMessageListenerContainer.class);
assertThat(TestUtils.getPropertyValue(container, "missingQueuesFatal", Boolean.class)).isFalse();
assertThat(container.isRunning()).isTrue();
consumerBinding.unbind();
assertThat(container.isRunning()).isFalse();
RabbitManagementTemplate rmt = new RabbitManagementTemplate();
List<org.springframework.amqp.core.Binding> bindings = rmt.getBindingsForExchange("/", exchange.getName());
assertThat(bindings.size()).isEqualTo(1);
}
示例7: rabbitAdmin
import org.springframework.amqp.rabbit.core.RabbitAdmin; //导入方法依赖的package包/类
@Bean
@Required
RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory, FanoutExchange fanoutExchange, Queue eventStream, Binding binding) {
RabbitAdmin admin = new RabbitAdmin(connectionFactory);
admin.setAutoStartup(true);
admin.declareExchange(fanoutExchange);
admin.declareQueue(eventStream);
admin.declareBinding(binding);
return admin;
}
示例8: declareExchange
import org.springframework.amqp.rabbit.core.RabbitAdmin; //导入方法依赖的package包/类
/**
* decalre specified excahnge
* @param connectionFactory
* @param exchangeType
* @param exchangeName
* @param durable
* @param autoDelete
*/
public static void declareExchange(ConnectionFactory connectionFactory,
String exchangeType,
String exchangeName,
boolean durable,
boolean autoDelete) {
Exchange x = createExchange(exchangeType, exchangeName, durable, autoDelete);
RabbitAdmin admin = new RabbitAdmin(connectionFactory);
admin.declareExchange(x);
}
示例9: call
import org.springframework.amqp.rabbit.core.RabbitAdmin; //导入方法依赖的package包/类
@Override
public RabbitTemplate call() throws Exception {
ConnectionFactory connectionFactory = connectionFactoryProvider.getObject();
Assert.notNull(connectionFactory, "connectionFactory is null");
if(exchangeFactory != null) {
Exchange exchange = exchangeFactory.call();
if(exchange != null) {
RabbitAdmin admin = new RabbitAdmin(connectionFactory);
admin.declareExchange(exchange);
}
}
return new RabbitTemplate(connectionFactory);
}
示例10: init
import org.springframework.amqp.rabbit.core.RabbitAdmin; //导入方法依赖的package包/类
@PostConstruct
private void init() {
log.info("Initialization of RabbitConfiguration");
rabbitAdmin = new RabbitAdmin(connectionFactory);
TopicExchange topicExchange = new TopicExchange("openbaton-exchange");
rabbitAdmin.declareExchange(topicExchange);
log.info("exchange declared");
}
示例11: init
import org.springframework.amqp.rabbit.core.RabbitAdmin; //导入方法依赖的package包/类
@PostConstruct
private void init() throws IOException {
log.info("Initialization of VnfmSpringHelperRabbit");
rabbitAdmin = new RabbitAdmin(connectionFactory);
rabbitAdmin.declareExchange(new TopicExchange("openbaton-exchange"));
rabbitAdmin.declareQueue(
new Queue(RabbitConfiguration.queueName_vnfmRegister, true, exclusive, autodelete));
rabbitAdmin.declareBinding(
new Binding(
RabbitConfiguration.queueName_vnfmRegister,
Binding.DestinationType.QUEUE,
"openbaton-exchange",
RabbitConfiguration.queueName_vnfmRegister,
null));
}