Package org.springframework.amqp.rabbit.core

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


  @Test
  public void testHardErrorAndReconnect() throws Exception {

    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    RabbitAdmin admin = new RabbitAdmin(connectionFactory);
    Queue queue = new Queue("foo");
    admin.declareQueue(queue);
    final String route = queue.getName();

    final CountDownLatch latch = new CountDownLatch(1);
    try {
      template.execute(new ChannelCallback<Object>() {
View Full Code Here


  }

  @Test
  public void testDeclaredBy() throws Exception {
    Queue queue = beanFactory.getBean("autoDeclareTwoAdmins", Queue.class);
    RabbitAdmin admin1 = beanFactory.getBean("admin1", RabbitAdmin.class);
    RabbitAdmin admin2 = beanFactory.getBean("admin2", RabbitAdmin.class);
    assertEquals(2, queue.getDeclaringAdmins().size());
    assertTrue(queue.getDeclaringAdmins().contains(admin1));
    assertTrue(queue.getDeclaringAdmins().contains(admin2));
    assertTrue(queue.shouldDeclare());
View Full Code Here

      // Context was invalid
      return;
    }

    // Validate values
    RabbitAdmin admin;
    if (StringUtils.hasText(adminBeanName)) {
      admin = beanFactory.getBean(adminBeanName, RabbitAdmin.class);
    } else {
      admin = beanFactory.getBean(RabbitAdmin.class);
    }
    assertEquals(expectedAutoStartup, admin.isAutoStartup());
    assertEquals(beanFactory.getBean(ConnectionFactory.class), admin.getRabbitTemplate().getConnectionFactory());

    if (initialisedWithTemplate) {
      assertEquals(beanFactory.getBean(RabbitTemplate.class), admin.getRabbitTemplate());
    }

  }
View Full Code Here

      if (!admins.isEmpty()) {
        this.rabbitAdmin = admins.values().iterator().next();
      }
    }
    if (this.rabbitAdmin == null && this.autoDeclare) {
      RabbitAdmin rabbitAdmin = new RabbitAdmin(this.getConnectionFactory());
      rabbitAdmin.setApplicationContext(this.getApplicationContext());
      this.rabbitAdmin = rabbitAdmin;
    }
    synchronized (this.consumersMonitor) {
      int newConsumers = initializeConsumers();
      if (this.consumers == null) {
View Full Code Here

  @Test
  public void testGetQueues() throws Exception {
    SingleConnectionFactory connectionFactory = new SingleConnectionFactory();
    connectionFactory.setPort(BrokerTestUtils.getAdminPort());
    Queue queue = new RabbitAdmin(connectionFactory).declareQueue();
    assertEquals("/", connectionFactory.getVirtualHost());
    List<QueueInfo> queues = brokerAdmin.getQueues();
    assertEquals(queue.getName(), queues.get(0).getName());
    connectionFactory.destroy();
  }
View Full Code Here

  /**
   * Maybe declare the exchange.
   */
  protected void maybeDeclareExchange() {
    RabbitAdmin admin = new RabbitAdmin(connectionFactory);
    if (declareExchange) {
      Exchange x;
      if ("topic".equals(exchangeType)) {
        x = new TopicExchange(exchangeName, durable, autoDelete);
      }
      else if ("direct".equals(exchangeType)) {
        x = new DirectExchange(exchangeName, durable, autoDelete);
      }
      else if ("fanout".equals(exchangeType)) {
        x = new FanoutExchange(exchangeName, durable, autoDelete);
      }
      else if ("headers".equals(exchangeType)) {
        x = new HeadersExchange(exchangeType, durable, autoDelete);
      }
      else {
        x = new TopicExchange(exchangeName, durable, autoDelete);
      }
      // admin.deleteExchange(exchangeName);
      admin.declareExchange(x);
    }
  }
View Full Code Here

  @Before
  public void setup() throws Exception {
    connectionFactory = new SingleConnectionFactory();
    connectionFactory.setHost("localhost");
    this.admin = new RabbitAdmin(this.connectionFactory);
    deleteQueues();
  }
View Full Code Here

  /**
   * Maybe declare the exchange.
   */
  protected void maybeDeclareExchange() {
    RabbitAdmin admin = new RabbitAdmin(this.connectionFactory);
    if (this.declareExchange) {
      Exchange x;
      if ("topic".equals(this.exchangeType)) {
        x = new TopicExchange(this.exchangeName, this.durable, this.autoDelete);
      }
      else if ("direct".equals(this.exchangeType)) {
        x = new DirectExchange(this.exchangeName, this.durable, this.autoDelete);
      }
      else if ("fanout".equals(this.exchangeType)) {
        x = new FanoutExchange(this.exchangeName, this.durable, this.autoDelete);
      }
      else if ("headers".equals(this.exchangeType)) {
        x = new HeadersExchange(this.exchangeType, this.durable, this.autoDelete);
      }
      else {
        x = new TopicExchange(this.exchangeName, this.durable, this.autoDelete);
      }
      admin.declareExchange(x);
    }
  }
View Full Code Here

    Queue queue = beanFactory.getBean("arguments", Queue.class);
    assertNotNull(queue);
    CachingConnectionFactory connectionFactory = new CachingConnectionFactory(BrokerTestUtils.getPort());
    connectionFactory.setHost("localhost");
    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    RabbitAdmin rabbitAdmin = new RabbitAdmin(template.getConnectionFactory());
    rabbitAdmin.deleteQueue(queue.getName());
    rabbitAdmin.declareQueue(queue);

    assertEquals(100L, queue.getArguments().get("x-message-ttl"));
    template.convertAndSend(queue.getName(), "message");

    Thread.sleep(200);
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.