Package org.springframework.amqp.rabbit.listener

Examples of org.springframework.amqp.rabbit.listener.BlockingQueueConsumer


    template.execute(new ChannelCallback<Void>() {
      @Override
      public Void doInRabbit(Channel channel) throws Exception {

        BlockingQueueConsumer consumer = createConsumer(template);
        String tag = consumer.getConsumerTag();
        assertNotNull(tag);

        template.convertAndSend("foo", "message");

        try {

          String result = getResult(consumer);
          assertEquals(null, result);

          template.convertAndSend("foo.end", "message");
          result = getResult(consumer);
          assertEquals("message", result);

        } finally {
          consumer.getChannel().basicCancel(tag);
        }

        return null;

      }
View Full Code Here


    template.execute(new ChannelCallback<Void>() {
      @Override
      public Void doInRabbit(Channel channel) throws Exception {

        BlockingQueueConsumer consumer = createConsumer(template);
        String tag = consumer.getConsumerTag();
        assertNotNull(tag);

        template.convertAndSend("topic", "foo", "message");

        try {

          String result = getResult(consumer);
          assertEquals(null, result);

          template.convertAndSend("topic", "foo.end", "message");
          result = getResult(consumer);
          assertEquals("message", result);

        } finally {
          consumer.getChannel().basicCancel(tag);
        }

        return null;

      }
View Full Code Here

    final CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
    cachingConnectionFactory.setHost("localhost");
    final RabbitTemplate template = new RabbitTemplate(cachingConnectionFactory);
    template.setExchange(exchange.getName());

    BlockingQueueConsumer consumer = template.execute(new ChannelCallback<BlockingQueueConsumer>() {
      @Override
      public BlockingQueueConsumer doInRabbit(Channel channel) throws Exception {

        BlockingQueueConsumer consumer = createConsumer(template);
        String tag = consumer.getConsumerTag();
        assertNotNull(tag);

        return consumer;

      }
    });

    template.convertAndSend("foo", "message");
    String result = getResult(consumer);
    assertEquals(null, result);

    template.convertAndSend("foo.end", "message");
    result = getResult(consumer);
    assertEquals("message", result);

    consumer.stop();
    cachingConnectionFactory.destroy();

  }
View Full Code Here

    template.execute(new ChannelCallback<Void>() {
      @Override
      public Void doInRabbit(Channel channel) throws Exception {

        BlockingQueueConsumer consumer = createConsumer(template);
        String tag = consumer.getConsumerTag();
        assertNotNull(tag);

        try {
          template.convertAndSend("foo", "message");
          String result = getResult(consumer);
          assertEquals(null, result);
        } finally {
          consumer.stop();
        }

        return null;

      }
    });

    template.execute(new ChannelCallback<Void>() {
      @Override
      public Void doInRabbit(Channel channel) throws Exception {

        BlockingQueueConsumer consumer = createConsumer(template);
        String tag = consumer.getConsumerTag();
        assertNotNull(tag);

        try {
          template.convertAndSend("foo.end", "message");
          String result = getResult(consumer);
          assertEquals("message", result);
        } finally {
          consumer.stop();
        }

        return null;

      }
View Full Code Here

    template.execute(new ChannelCallback<Void>() {
      @Override
      public Void doInRabbit(Channel channel) throws Exception {

        BlockingQueueConsumer consumer = createConsumer(template);
        String tag = consumer.getConsumerTag();
        assertNotNull(tag);

        try {
          template.convertAndSend("message");
          String result = getResult(consumer);
          assertEquals("message", result);
        } finally {
          consumer.stop();
        }

        return null;

      }
View Full Code Here

    });

  }

  private BlockingQueueConsumer createConsumer(RabbitAccessor accessor) {
    BlockingQueueConsumer consumer = new BlockingQueueConsumer(
        accessor.getConnectionFactory(), new DefaultMessagePropertiesConverter(),
        new ActiveObjectCounter<BlockingQueueConsumer>(), AcknowledgeMode.AUTO, true, 1, queue.getName());
    consumer.start();
    // wait for consumeOk...
    int n = 0;
    while (n++ < 100) {
      if (consumer.getConsumerTag() == null) {
        try {
          Thread.sleep(100);
        }
        catch (InterruptedException e) {
          Thread.currentThread().interrupt();
View Full Code Here

TOP

Related Classes of org.springframework.amqp.rabbit.listener.BlockingQueueConsumer

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.