Example usage for org.springframework.amqp.rabbit.listener SimpleMessageListenerContainer setTransactionManager

List of usage examples for org.springframework.amqp.rabbit.listener SimpleMessageListenerContainer setTransactionManager

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.listener SimpleMessageListenerContainer setTransactionManager.

Prototype

public void setTransactionManager(PlatformTransactionManager transactionManager) 

Source Link

Document

Set the transaction manager to use.

Usage

From source file:org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainerTests.java

@Test
public void testChannelTransactedOverriddenWhenTxManager() throws Exception {
    final SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory("localhost");
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(singleConnectionFactory);
    container.setMessageListener(new MessageListenerAdapter(this));
    container.setQueueNames("foo");
    container.setChannelTransacted(false);
    container.setTransactionManager(new TestTransactionManager());
    container.afterPropertiesSet();// www.j a  v a2  s. c o m
    assertTrue(TestUtils.getPropertyValue(container, "transactional", Boolean.class));
    container.stop();
    singleConnectionFactory.destroy();
}

From source file:org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainerTests.java

@Test
public void testInconsistentTransactionConfiguration() throws Exception {
    final SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory("localhost");
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(singleConnectionFactory);
    container.setMessageListener(new MessageListenerAdapter(this));
    container.setQueueNames("foo");
    container.setChannelTransacted(false);
    container.setAcknowledgeMode(AcknowledgeMode.NONE);
    container.setTransactionManager(new TestTransactionManager());
    expectedException.expect(IllegalStateException.class);
    container.afterPropertiesSet();//from   w  w w . j a va 2  s  . c  om
    container.stop();
    singleConnectionFactory.destroy();
}