Examples of convertAndSend()


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

    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

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

    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

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

    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

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

  }

  @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

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

    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

Examples of org.springframework.data.keyvalue.redis.core.StringRedisTemplate.convertAndSend()

  }

  @Test
  public void testWithMessages() throws Exception {
    StringRedisTemplate template = ctx.getBean(StringRedisTemplate.class);
    template.convertAndSend("x1", "[X]test");
    template.convertAndSend("z1", "[Z]test");
    //Thread.sleep(TimeUnit.SECONDS.toMillis(5));
  }

  @Test
View Full Code Here

Examples of org.springframework.data.keyvalue.redis.core.StringRedisTemplate.convertAndSend()

  @Test
  public void testWithMessages() throws Exception {
    StringRedisTemplate template = ctx.getBean(StringRedisTemplate.class);
    template.convertAndSend("x1", "[X]test");
    template.convertAndSend("z1", "[Z]test");
    //Thread.sleep(TimeUnit.SECONDS.toMillis(5));
  }

  @Test
  public void testErrorHandler() throws Exception {
View Full Code Here

Examples of org.springframework.data.keyvalue.redis.core.StringRedisTemplate.convertAndSend()

  public void testErrorHandler() throws Exception {
    StubErrorHandler handler = ctx.getBean(StubErrorHandler.class);
   
    int index = handler.throwables.size();
    StringRedisTemplate template = ctx.getBean(StringRedisTemplate.class);
    template.convertAndSend("exception", "test1");
    handler.throwables.pollLast(3, TimeUnit.SECONDS);
    assertEquals(index + 1, handler.throwables.size());
  }
}
View Full Code Here

Examples of org.springframework.integration.core.MessagingTemplate.convertAndSend()

    gateway.setReceiveTimeout(500L);
    gateway.afterPropertiesSet();

    JobConfigurationRequest request = new JobConfigurationRequest();
    request.setXml(IOUtils.toString(new ClassPathResource("/staging-context.xml").getInputStream()));
    gateway.convertAndSend(requests, request);
    assertNotNull("Time out waiting for reply", result);
     assertEquals("[staging]", result.toString());
    
  }
View Full Code Here

Examples of org.springframework.integration.core.MessagingTemplate.convertAndSend()

    Order order = new Order(orderId);
    order.setEmail(email);
    order.setQuantity(quantity);
    order.setProductId(productId);
    MessagingTemplate template = new MessagingTemplate(this.orderChannel);
    template.convertAndSend(order);
    model.addAttribute("orderId", orderId);
    return "order";
  }

}
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.