Package org.springframework.amqp.rabbit.core

Examples of org.springframework.amqp.rabbit.core.RabbitAdmin


    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(template.getConnectionFactory());
    MessageListenerAdapter messageListener = new MessageListenerAdapter();
    messageListener.setDelegate(new Object());
    container.setMessageListener(messageListener);

    RabbitAdmin admin = new RabbitAdmin(template.getConnectionFactory());
    Map<String, Object> args = new HashMap<String, Object>();
    args.put("x-dead-letter-exchange", "test.DLE");
    Queue queue = new Queue("", false, false, true, args);
    String testQueueName = admin.declareQueue(queue);
    // Create a DeadLetterExchange and bind a queue to it with the original routing key
    DirectExchange dle = new DirectExchange("test.DLE", false, true);
    admin.declareExchange(dle);
    Queue dlq = new AnonymousQueue();
    admin.declareQueue(dlq);
    admin.declareBinding(BindingBuilder.bind(dlq).to(dle).with(testQueueName));

    container.setQueueNames(testQueueName);
    container.afterPropertiesSet();
    container.start();
View Full Code Here


    /**
     * @return an admin to handle the declarations.
     */
    @Bean
    public RabbitAdmin admin() {
      return new RabbitAdmin(rabbitConnectionFactory());
    }
View Full Code Here

  public void declareQueues() {
    CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
    connectionFactory.setHost("localhost");
    connectionFactory.setPort(BrokerTestUtils.getPort());
    template.setConnectionFactory(connectionFactory);
    admin = new RabbitAdmin(connectionFactory);
    admin.deleteQueue(queue.getName());
    admin.declareQueue(queue);
    admin.deleteQueue(queue1.getName());
    admin.declareQueue(queue1);
  }
View Full Code Here

      connectionFactory.setPort(port);
      if (StringUtils.hasText(hostName)) {
        connectionFactory.setHost(hostName);
      }
      RabbitAdmin admin = new RabbitAdmin(connectionFactory);

      for (Queue queue : queues) {
        String queueName = queue.getName();

        if (purge) {
          logger.debug("Deleting queue: " + queueName);
          // Delete completely - gets rid of consumers and bindings as well
          admin.deleteQueue(queueName);
        }

        if (isDefaultQueue(queueName)) {
          // Just for test probe.
          admin.deleteQueue(queueName);
        }
        else {
          admin.declareQueue(queue);
        }
      }
      brokerOffline.put(port, false);
      if (!assumeOnline) {
        Assume.assumeTrue(brokerOffline.get(port));
View Full Code Here

    return BindingBuilder.bind(testQueue()).to(testExchange()).with(ROUTING_KEY);
  }

  @Bean
  public RabbitAdmin rabbitAdmin() {
    return new RabbitAdmin(connectionFactory());
  }
View Full Code Here

  @Scope(BeanDefinition.SCOPE_PROTOTYPE)
  public SimpleMessageListenerContainer listenerContainer() {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory());
    Queue q = testQueue();

    RabbitAdmin admin = rabbitAdmin();
    admin.declareQueue(q);
    admin.declareBinding(testBinding());

    container.setQueues(q);
    // container.setMessageListener(testListener(4));
    container.setAutoStartup(false);
    container.setAcknowledgeMode(AcknowledgeMode.AUTO);
View Full Code Here

      }
    });
    container.setConcurrentConsumers(2);
    container.afterPropertiesSet();

    RabbitAdmin admin = new RabbitAdmin(connectionFactory);
    for (int i = 0; i < 20; i++) {
      AnonymousQueue anonymousQueue = new AnonymousQueue();
      admin.declareQueue(anonymousQueue);
      container.addQueueNames(anonymousQueue.getName());
      if (!container.isRunning()) {
        container.start();
      }
    }
View Full Code Here

  public void testStopStart() throws Exception {
    RabbitTemplate template = context.getBean(RabbitTemplate.class);
    template.convertAndSend("testContainerWithAutoDeleteQueues", "anon", "foo");
    assertNotNull(queue.poll(10, TimeUnit.SECONDS));
    this.listenerContainer1.stop();
    RabbitAdmin admin = spy(TestUtils.getPropertyValue(this.listenerContainer1, "rabbitAdmin", RabbitAdmin.class));
    new DirectFieldAccessor(this.listenerContainer1).setPropertyValue("rabbitAdmin", admin);
    this.listenerContainer1.start();
    template.convertAndSend("testContainerWithAutoDeleteQueues", "anon", "foo");
    assertNotNull(queue.poll(10, TimeUnit.SECONDS));
    verify(admin, times(1)).initialize(); // should only be called by one of the consumers
View Full Code Here

    template.convertAndSend("xExpires", "foo");
    assertNotNull(queue.poll(10, TimeUnit.SECONDS));
    SimpleMessageListenerContainer listenerContainer = context.getBean("container3",
        SimpleMessageListenerContainer.class);
    listenerContainer.stop();
    RabbitAdmin admin = spy(TestUtils.getPropertyValue(listenerContainer, "rabbitAdmin", RabbitAdmin.class));
    new DirectFieldAccessor(listenerContainer).setPropertyValue("rabbitAdmin", admin);
    int n = 0;
    while (admin.getQueueProperties("xExpires") != null && n < 100) {
      Thread.sleep(100);
      n++;
    }
    assertTrue(n < 100);
    listenerContainer.start();
View Full Code Here

    template.convertAndSend("testContainerWithAutoDeleteQueues", "anon2", "foo");
    assertNotNull(queue.poll(10, TimeUnit.SECONDS));
    SimpleMessageListenerContainer listenerContainer = context.getBean("container4",
        SimpleMessageListenerContainer.class);
    listenerContainer.stop();
    RabbitAdmin admin = spy(TestUtils.getPropertyValue(listenerContainer, "rabbitAdmin", RabbitAdmin.class));
    new DirectFieldAccessor(listenerContainer).setPropertyValue("rabbitAdmin", admin);
    listenerContainer = spy(listenerContainer);

    //Prevent a long 'passiveDeclare' process
    BlockingQueueConsumer consumer = mock(BlockingQueueConsumer.class);
View Full Code Here

TOP

Related Classes of org.springframework.amqp.rabbit.core.RabbitAdmin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.