当前位置: 首页>>代码示例>>Java>>正文


Java RabbitAdmin.declareExchange方法代码示例

本文整理汇总了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;
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:26,代码来源:CheckBrokerConnectionUtils.java

示例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));
}
 
开发者ID:openbaton,项目名称:generic-vnfm,代码行数:19,代码来源:EMSConfiguration.java

示例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);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:19,代码来源:ApplicationContextRabbitmqTest.java

示例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;
}
 
开发者ID:drm317,项目名称:cloud-native-reference,代码行数:11,代码来源:RabbitConfiguration.java

示例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;
}
 
开发者ID:drm317,项目名称:cloud-native-reference,代码行数:11,代码来源:RabbitConfiguration.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:28,代码来源:RabbitBinderTests.java

示例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;
}
 
开发者ID:benwilcock,项目名称:cf-cqrs-microservice-sampler,代码行数:11,代码来源:AxonConfiguration.java

示例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);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:18,代码来源:AmqpUtils.java

示例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);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:16,代码来源:AmqpReporter.java

示例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");
}
 
开发者ID:openbaton,项目名称:openbaton-libs,代码行数:9,代码来源:RabbitConfiguration.java

示例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));
}
 
开发者ID:openbaton,项目名称:openbaton-libs,代码行数:16,代码来源:VnfmSpringHelperRabbit.java


注:本文中的org.springframework.amqp.rabbit.core.RabbitAdmin.declareExchange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。