Package org.springframework.amqp.rabbit.core

Examples of org.springframework.amqp.rabbit.core.RabbitTemplate.receiveAndConvert()


    template.convertAndSend("Hello, Rabbit!");
    template.convertAndSend("Hello, AMQP!");

    int count = 0;
    while (true) {
      String message = (String) template.receiveAndConvert();
      if (message == null) {
        break;
      }
      else {
        count++;
View Full Code Here


  }

  @Override
  protected void verifyOnDemandQueues(MessageChannel y3, MessageChannel z3) {
    RabbitTemplate template = new RabbitTemplate(rabbitAvailableRule.getResource());
    Object y = template.receiveAndConvert("xdbus.queue:y");
    assertNotNull(y);
    assertEquals("y", y);
    Object z = template.receiveAndConvert("xdbus.queue:z");
    assertNotNull(z);
    assertEquals("z", z);
View Full Code Here

    RabbitTemplate template = new RabbitTemplate(this.rabbitAvailableRule.getResource());
    template.convertAndSend("", "xdbustest.dlqtest", "foo");

    int n = 0;
    while (n++ < 100) {
      Object deadLetter = template.receiveAndConvert("xdbustest.dlqtest.dlq");
      if (deadLetter != null) {
        assertEquals("foo", deadLetter);
        break;
      }
      Thread.sleep(100);
View Full Code Here

  protected void verifyOnDemandQueues(MessageChannel y3, MessageChannel z3) {
    RabbitTemplate template = new RabbitTemplate(rabbitAvailableRule.getResource());
    Object y = template.receiveAndConvert("xdbus.queue:y");
    assertNotNull(y);
    assertEquals("y", y);
    Object z = template.receiveAndConvert("xdbus.queue:z");
    assertNotNull(z);
    assertEquals("z", z);
  }

  @Override
View Full Code Here

      @Override
      public Object receive(boolean expectNull) throws Exception {
        if (expectNull) {
          Thread.sleep(50);
          return template.receiveAndConvert("xdbus." + queue);
        }
        Object bar = null;
        int n = 0;
        while (n++ < 100 && bar == null) {
          bar = template.receiveAndConvert("xdbus." + queue);
View Full Code Here

          return template.receiveAndConvert("xdbus." + queue);
        }
        Object bar = null;
        int n = 0;
        while (n++ < 100 && bar == null) {
          bar = template.receiveAndConvert("xdbus." + queue);
          Thread.sleep(100);
        }
        assertTrue("Message did not arrive in RabbitMQ", n < 100);
        return bar;
      }
View Full Code Here

        assertTrue("Expected to receive all messages before stop", waited);
      }

      assertTrue("Not enough error handling, remaining:" + this.errorsHandled.getCount(),
          this.errorsHandled.await(10, TimeUnit.SECONDS));
      assertNull(template.receiveAndConvert(queue.getName()));
    }
    finally {
      container.shutdown();
    }
View Full Code Here

    int timeout = Math.min(4 + messageCount / (4 * concurrentConsumers), 30);
    logger.debug("Waiting for messages with timeout = " + timeout + " (s)");
    boolean waited = latch.await(timeout, TimeUnit.SECONDS);
    assertTrue("Timed out waiting for message", waited);

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

  }

  private ConnectionFactory createConnectionFactory() {
    CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
View Full Code Here

    int timeout = Math.min(4 + messageCount / (4 * concurrentConsumers), 30);
    logger.debug("Waiting for messages with timeout = " + timeout + " (s)");
    waited = latch.await(timeout, TimeUnit.SECONDS);
    assertTrue("Timed out waiting for message", waited);

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

  }

  private SimpleMessageListenerContainer createContainer(String queueName, Object listener,
      ConnectionFactory connectionFactory) {
View Full Code Here

    blockingQueueConsumer.start();

    // TODO: make this into a proper assertion. An exception can be thrown here by the Rabbit client and printed to
    // stderr without being rethrown (so hard to make a test fail).
    blockingQueueConsumer.stop();
    assertNull(template.receiveAndConvert(queue.getName()));
    connectionFactory.destroy();

  }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.