當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。