Example usage for org.springframework.amqp.rabbit.core RabbitTemplate setChannelTransacted

List of usage examples for org.springframework.amqp.rabbit.core RabbitTemplate setChannelTransacted

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.core RabbitTemplate setChannelTransacted.

Prototype

public void setChannelTransacted(boolean transactional) 

Source Link

Document

Flag to indicate that channels created by this component will be transactional.

Usage

From source file:com.springsource.open.foo.ListenerApplication.java

@Bean
public RabbitTemplate jmsTemplate(ConnectionFactory connectionFactory) {
    RabbitTemplate jmsTemplate = new RabbitTemplate(connectionFactory);
    jmsTemplate.setReceiveTimeout(200);//w  w  w. j  a  va  2  s .c  om
    jmsTemplate.setChannelTransacted(true);
    return jmsTemplate;
}

From source file:org.springframework.amqp.rabbit.core.RabbitTemplateIntegrationTests.java

@Test
public void testSendAndReceiveTransactedWithUncachedConnection() throws Exception {
    RabbitTemplate template = new RabbitTemplate(new SingleConnectionFactory());
    template.setChannelTransacted(true);
    template.convertAndSend(ROUTE, "message");
    String result = (String) template.receiveAndConvert(ROUTE);
    assertEquals("message", result);
    result = (String) template.receiveAndConvert(ROUTE);
    assertEquals(null, result);//from  ww w  .ja v  a2s .  co m
}