Package org.springframework.amqp.rabbit.listener.adapter

Examples of org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter


  @Test
  public void testDefaultConsumerCount() throws Exception {
    final SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory("localhost");
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(singleConnectionFactory);
    container.setMessageListener(new MessageListenerAdapter(this));
    container.setQueueNames("foo");
    container.setAutoStartup(false);
    container.afterPropertiesSet();
    assertEquals(1, ReflectionTestUtils.getField(container, "concurrentConsumers"));
    container.stop();
View Full Code Here


  @Test
  public void testChangeConsumerCount() throws Exception {
    final SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory("localhost");
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(singleConnectionFactory);
    container.setMessageListener(new MessageListenerAdapter(this));
    container.setQueueNames("foo");
    container.setAutoStartup(false);
    container.setConcurrentConsumers(2);
    container.afterPropertiesSet();
    assertEquals(2, ReflectionTestUtils.getField(container, "concurrentConsumers"));
View Full Code Here

    assertNull(template.receiveAndConvert(queue.getName()));
  }

  private SimpleMessageListenerContainer createContainer(Object listener) {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(template.getConnectionFactory());
    container.setMessageListener(new MessageListenerAdapter(listener));
    container.setQueueNames(queue.getName());
    container.setTxSize(txSize);
    container.setPrefetchCount(txSize);
    container.setConcurrentConsumers(concurrentConsumers);
    container.setChannelTransacted(transactional);
View Full Code Here

    // 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);
    }
View Full Code Here

  }

  protected SimpleMessageListenerContainer doCreateContainer(String queueName, Object listener,
      ConnectionFactory connectionFactory) {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
    container.setMessageListener(new MessageListenerAdapter(listener));
    container.setQueueNames(queueName);
    container.setConcurrentConsumers(concurrentConsumers);
    container.setChannelTransacted(transactional);
    container.setAcknowledgeMode(acknowledgeMode);
    container.afterPropertiesSet();
View Full Code Here

    container.setQueueNames("foo");
    container.setPrefetchCount(1000);
    container.setTxSize(500);
    container.setAcknowledgeMode(AcknowledgeMode.AUTO);
    container.setConcurrentConsumers(20);
    container.setMessageListener(new MessageListenerAdapter(new SimpleAdapter(),messageConverter));
    container.start();

    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    template.setMessageConverter(messageConverter);
    List<BlockingQueue<?>> queues = getQueues(container);
View Full Code Here

      template.convertAndSend(queue.getName(), i + "foo");
    }

    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
    PojoListener listener = new PojoListener(latch);
    container.setMessageListener(new MessageListenerAdapter(listener));
    container.setAcknowledgeMode(transactionMode.getAcknowledgeMode());
    container.setChannelTransacted(transactionMode.isTransactional());
    container.setConcurrentConsumers(concurrentConsumers);

    if (transactionMode.getPrefetch() > 0) {
View Full Code Here

    }).when(log).debug(
        Mockito.contains("Consumer received Shutdown Signal, processing stopped"));
    DirectFieldAccessor dfa = new DirectFieldAccessor(container);
    dfa.setPropertyValue("logger", log);
    container.setQueues(queue);
    container.setMessageListener(new MessageListenerAdapter());
    container.afterPropertiesSet();
    container.start();

    try {
      connectionFactory.destroy();
View Full Code Here

      template.convertAndSend(queue2.getName(), new Integer(i));
    }
    final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
    final CountDownLatch latch = new CountDownLatch(messageCount * 2);
    PojoListener listener = new PojoListener(latch);
    container.setMessageListener(new MessageListenerAdapter(listener));
    container.setAcknowledgeMode(AcknowledgeMode.AUTO);
    container.setChannelTransacted(true);
    container.setConcurrentConsumers(concurrentConsumers);
    configurer.configure(container);
    container.afterPropertiesSet();
View Full Code Here

  }

  @Test
  public void testPojoListenerSunnyDay() throws Exception {
    CountDownLatch latch = new CountDownLatch(messageCount);
    doSunnyDayTest(latch, new MessageListenerAdapter(new PojoListener(latch)));
  }
View Full Code Here

TOP

Related Classes of org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter

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.