Package org.springframework.amqp.rabbit.core

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


    Advice retryInterceptor = fb.getObject();
    // add both advices
    container.setAdviceChain(new Advice[] {missingIdAdvice, retryInterceptor});
    container.start();

    template.convertAndSend("retry.test.exchange", "retry.test.binding", "Hello, world!");
    template.convertAndSend("retry.test.exchange", "retry.test.binding", "Hello, world!");
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    Thread.sleep(2000);
    assertEquals(0, ((Map) new DirectFieldAccessor(cache).getPropertyValue("map")).size());
    container.stop();
View Full Code Here


    // add both advices
    container.setAdviceChain(new Advice[] {missingIdAdvice, retryInterceptor});
    container.start();

    template.convertAndSend("retry.test.exchange", "retry.test.binding", "Hello, world!");
    template.convertAndSend("retry.test.exchange", "retry.test.binding", "Hello, world!");
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    Thread.sleep(2000);
    assertEquals(0, ((Map) new DirectFieldAccessor(cache).getPropertyValue("map")).size());
    container.stop();
    ctx.close();
View Full Code Here

      @Override
      public void onMessage(Message message) {
        RabbitTemplate rabbitTemplate = new RabbitTemplate(cachingConnectionFactory);
        rabbitTemplate.setChannelTransacted(true);
        // should use same channel as container
        rabbitTemplate.convertAndSend("foo", "bar", "baz");
        latch.countDown();
      }
    });
    container.setQueueNames("queue");
    container.setChannelTransacted(true);
View Full Code Here

      public void onMessage(Message message, Channel channel) {
        exposed.set(channel);
        RabbitTemplate rabbitTemplate = new RabbitTemplate(singleConnectionFactory);
        rabbitTemplate.setChannelTransacted(true);
        // should use same channel as container
        rabbitTemplate.convertAndSend("foo", "bar", "baz");
        latch.countDown();
      }

    });
    container.setQueueNames("queue");
View Full Code Here

      public void onMessage(Message message, Channel channel) {
        exposed.set(channel);
        RabbitTemplate rabbitTemplate = new RabbitTemplate(singleConnectionFactory);
        rabbitTemplate.setChannelTransacted(true);
        // should use same channel as container
        rabbitTemplate.convertAndSend("foo", "bar", "baz");
        latch.countDown();
      }

    });
    container.setQueueNames("queue");
View Full Code Here

    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    CountDownLatch latch = new CountDownLatch(messageCount);
    listener.setLatch(latch);

    for (int i = 0; i < messageCount; i++) {
      template.convertAndSend(queue.getName(), i + "foo");
    }

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

    CountDownLatch latch = new CountDownLatch(messageCount);
    assertEquals("No more messages to receive before even sent!", messageCount, latch.getCount());
    container = createContainer(queue.getName(), new VanillaListener(latch), connectionFactory);
    for (int i = 0; i < messageCount; i++) {
      template.convertAndSend(queue.getName(), i + "foo");
    }

    assertTrue("No more messages to receive before broker stopped", latch.getCount() > 0);
    brokerAdmin.stopBrokerApplication();
    assertTrue("No more messages to receive after broker stopped", latch.getCount() > 0);
View Full Code Here

    container.setConcurrentConsumers(1);
    waitForNConsumers(container, 1);
    container.setMaxConcurrentConsumers(3);
    RabbitTemplate template = new RabbitTemplate(singleConnectionFactory);
    for (int i = 0; i < 20; i++) {
      template.convertAndSend("foo", "foo");
    }
    waitForNConsumers(container, 2);    // increased consumers due to work
    waitForNConsumers(container, 1, 20000); // should stop the extra consumer after 10 seconds idle
    container.setConcurrentConsumers(3);
    waitForNConsumers(container, 3);
View Full Code Here

  }

  @Test
  public void testStopStart() throws Exception {
    RabbitTemplate template = context.getBean(RabbitTemplate.class);
    template.convertAndSend("testContainerWithAutoDeleteQueues", "anon", "foo");
    assertNotNull(queue.poll(10, TimeUnit.SECONDS));
    this.listenerContainer1.stop();
    RabbitAdmin admin = spy(TestUtils.getPropertyValue(this.listenerContainer1, "rabbitAdmin", RabbitAdmin.class));
    new DirectFieldAccessor(this.listenerContainer1).setPropertyValue("rabbitAdmin", admin);
    this.listenerContainer1.start();
View Full Code Here

    assertNotNull(queue.poll(10, TimeUnit.SECONDS));
    this.listenerContainer1.stop();
    RabbitAdmin admin = spy(TestUtils.getPropertyValue(this.listenerContainer1, "rabbitAdmin", RabbitAdmin.class));
    new DirectFieldAccessor(this.listenerContainer1).setPropertyValue("rabbitAdmin", admin);
    this.listenerContainer1.start();
    template.convertAndSend("testContainerWithAutoDeleteQueues", "anon", "foo");
    assertNotNull(queue.poll(10, TimeUnit.SECONDS));
    verify(admin, times(1)).initialize(); // should only be called by one of the consumers
  }

  @Test
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.