Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.Queue


    container.setQueueNames("foo");
    List<?> queues = TestUtils.getPropertyValue(container, "queueNames", List.class);
    assertEquals(1, queues.size());
    container.addQueues(new AnonymousQueue(), new AnonymousQueue());
    assertEquals(3, queues.size());
    container.removeQueues(new Queue("foo"));
    assertEquals(2, queues.size());
    container.stop();
  }
View Full Code Here


    return new TopicExchange(EXCHANGE, true, false);
  }

  @Bean
  public Queue testQueue() {
    return new Queue(QUEUE);
  }
View Full Code Here

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

    RabbitAdmin admin = rabbitAdmin();
    admin.declareQueue(q);
    admin.declareBinding(testBinding());
View Full Code Here

      throws InterruptedException {
    RabbitAdmin admin = new RabbitAdmin(connectionFactory);
    // queue doesn't exist during startup - verify we started, create queue and verify recovery
    Thread.sleep(5000);
    assertEquals(messageCount, latch.getCount());
    admin.declareQueue(new Queue("nonexistent"));
    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    for (int i = 0; i < messageCount; i++) {
      template.convertAndSend("nonexistent", "foo" + i);
    }
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    Map<?,?> consumers = TestUtils.getPropertyValue(container, "consumers", Map.class);
    assertEquals(1, consumers.size());
    Object consumer = consumers.keySet().iterator().next();

    // delete the queue and verify we recover again when it is recreated.
    admin.deleteQueue("nonexistent");
    Thread.sleep(3000);
    latch = new CountDownLatch(messageCount);
    container.setMessageListener(new MessageListenerAdapter(new VanillaListener(latch)));
    assertEquals(messageCount, latch.getCount());
    admin.declareQueue(new Queue("nonexistent"));
    for (int i = 0; i < messageCount; i++) {
      template.convertAndSend("nonexistent", "foo" + i);
    }
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    assertEquals(1, consumers.size());
View Full Code Here

    assertEquals(beanFactory.getBean(ConnectionFactory.class), container.getConnectionFactory());
    assertEquals(MessageListenerAdapter.class, container.getMessageListener().getClass());
    DirectFieldAccessor listenerAccessor = new DirectFieldAccessor(container.getMessageListener());
    assertEquals(beanFactory.getBean(TestBean.class), listenerAccessor.getPropertyValue("delegate"));
    assertEquals("handle", listenerAccessor.getPropertyValue("defaultListenerMethod"));
    Queue queue = beanFactory.getBean("bar", Queue.class);
    assertEquals("[foo, "+queue.getName()+"]", Arrays.asList(container.getQueueNames()).toString());
  }
View Full Code Here

  public void testSendAndReceiveFromVolatileQueue() throws Exception {

    RabbitTemplate template = new RabbitTemplate(connectionFactory);

    RabbitAdmin admin = new RabbitAdmin(connectionFactory);
    Queue queue = admin.declareQueue();
    template.convertAndSend(queue.getName(), "message");
    String result = (String) template.receiveAndConvert(queue.getName());
    assertEquals("message", result);

  }
View Full Code Here

  public void testSendAndReceiveFromVolatileQueueAfterImplicitRemoval() throws Exception {

    RabbitTemplate template = new RabbitTemplate(connectionFactory);

    RabbitAdmin admin = new RabbitAdmin(connectionFactory);
    Queue queue = admin.declareQueue();
    template.convertAndSend(queue.getName(), "message");

    // Force a physical close of the channel
    connectionFactory.destroy();

    // The queue was removed when the channel was closed
    exception.expect(AmqpIOException.class);

    String result = (String) template.receiveAndConvert(queue.getName());
    assertEquals("message", result);

  }
View Full Code Here

    RabbitTemplate template1 = new RabbitTemplate(connectionFactory);
    RabbitTemplate template2 = new RabbitTemplate(connectionFactory);
    template1.setChannelTransacted(true);

    RabbitAdmin admin = new RabbitAdmin(connectionFactory);
    Queue queue = admin.declareQueue();

    template1.convertAndSend(queue.getName(), "message");
    String result = (String) template2.receiveAndConvert(queue.getName());
    assertEquals("message", result);

    // The channel is not transactional
    exception.expect(AmqpIOException.class);
View Full Code Here

  @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>() {
        @Override
View Full Code Here

    /**
     * @return an (auto-delete) queue.
     */
    @Bean
    public Queue requestQueue() {
      return new Queue("dlx.test.requestQ", false, false, true);
    }
View Full Code Here

TOP

Related Classes of org.springframework.amqp.core.Queue

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.