Package org.springframework.amqp.rabbit.core

Examples of org.springframework.amqp.rabbit.core.RabbitTemplate


    return TestUtils.getPropertyValue(endpoint, "handler.delegate.exchangeNameExpression", SpelExpression.class).getExpressionString();
  }

  @Override
  public Spy spyOn(final String queue) {
    final RabbitTemplate template = new RabbitTemplate(this.rabbitAvailableRule.getResource());
    return new Spy() {

      @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);
          Thread.sleep(100);
        }
        assertTrue("Message did not arrive in RabbitMQ", n < 100);
        return bar;
      }
View Full Code Here


   *
   * @param data String to be transmitted to the Broker.
   */
  public void sendData(String data) {
    Assert.hasText(data, "data must not be null nor empty");
    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    template.convertAndSend(DEFAULT_EXCHANGE, "rabbitfixture.source", data);
  }
View Full Code Here

        public RabbitMQMessageListener(SpringAMQPEndpoint endpoint) {
            this.listenerContainer = new SimpleMessageListenerContainer();
            this.listenerContainer.setTaskExecutor(new SpringAMQPExecutor(endpoint));

            RabbitTemplate template = (RabbitTemplate) endpoint.getAmqpTemplate();
            if(template != null) {
                this.msgConverter = template.getMessageConverter();
                this.listenerContainer.setConnectionFactory(template.getConnectionFactory());
            } else {
                LOG.error("No AMQP Template found! Cannot initialize message conversion or connections!");
            }

            this.listenerContainer.setQueueNames(endpoint.getQueueName());
View Full Code Here

            SpringAMQPMessage inMessage = new SpringAMQPMessage(message);
            exchange.setIn(inMessage); //Swap out the old message format

            MessageConverter msgConverter;
            if(endpoint.getAmqpTemplate() instanceof RabbitTemplate) {
                RabbitTemplate rabbitTemplate = (RabbitTemplate) endpoint.getAmqpTemplate();
                msgConverter = rabbitTemplate.getMessageConverter();
            } else {
                LOG.warn("Cannot find RabbitMQ AMQP Template, falling back to simple message converter");
                msgConverter = new SimpleMessageConverter();
            }
           
View Full Code Here

            }
        }
       
        if(this.amqpTemplate == null) {
            //Attempt to construct an AMQP template
            this.amqpTemplate = new RabbitTemplate(this.connectionFactory);
            LOG.info("Created new AMQP Template");
        }
       
        return this.amqpTemplate;
    }
View Full Code Here

        public RabbitMQMessageListener(SpringAMQPEndpoint endpoint) {
            this.listenerContainer = new SimpleMessageListenerContainer();
            this.listenerContainer.setTaskExecutor(new SpringAMQPExecutor(endpoint));

            RabbitTemplate template = (RabbitTemplate) endpoint.getAmqpTemplate();
            if(template != null) {
                this.msgConverter = template.getMessageConverter();
                this.listenerContainer.setConnectionFactory(template.getConnectionFactory());
            } else {
                LOG.error("No AMQP Template found! Cannot initialize message conversion or connections!");
            }

            this.listenerContainer.setQueueNames(endpoint.getQueueName());
View Full Code Here

            SpringAMQPMessage inMessage = new SpringAMQPMessage(message);
            exchange.setIn(inMessage); //Swap out the old message format

            MessageConverter msgConverter;
            if(endpoint.getAmqpTemplate() instanceof RabbitTemplate) {
                RabbitTemplate rabbitTemplate = (RabbitTemplate) endpoint.getAmqpTemplate();
                msgConverter = rabbitTemplate.getMessageConverter();
            } else {
                LOG.warn("Cannot find RabbitMQ AMQP Template, falling back to simple message converter");
                msgConverter = new SimpleMessageConverter();
            }
           
View Full Code Here

        }
       
        if(this.amqpTemplate == null || this.amqpTemplate.isEmpty()) {
            //Attempt to construct an AMQP template
            this.amqpTemplate = new HashMap<String, AmqpTemplate>();
            this.amqpTemplate.put(DEFAULT_CONNECTION, new RabbitTemplate(this.connectionFactory.values().iterator().next()));
            LOG.info("Created new AMQP Template");
        }
       
        return this.amqpTemplate;
    }
View Full Code Here

  private ConnectionFactory connectionFactory;

  @Bean
  @ConditionalOnMissingBean(RabbitTemplate.class)
  public RabbitTemplate rabbitTemplate() {
    return new RabbitTemplate(this.connectionFactory);
  }
View Full Code Here

  }

  @Test
  public void testDefaultRabbitConfiguration() {
    load(TestConfiguration.class);
    RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
    RabbitMessagingTemplate messagingTemplate = this.context
        .getBean(RabbitMessagingTemplate.class);
    CachingConnectionFactory connectionFactory = this.context
        .getBean(CachingConnectionFactory.class);
    RabbitAdmin amqpAdmin = this.context.getBean(RabbitAdmin.class);
    assertEquals(connectionFactory, rabbitTemplate.getConnectionFactory());
    assertEquals(rabbitTemplate, messagingTemplate.getRabbitTemplate());
    assertNotNull(amqpAdmin);
    assertEquals("localhost", connectionFactory.getHost());
    assertTrue("Listener container factory should be created by default",
        this.context.containsBean("rabbitListenerContainerFactory"));
View Full Code Here

TOP

Related Classes of org.springframework.amqp.rabbit.core.RabbitTemplate

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.