Package org.springframework.amqp.rabbit.connection

Examples of org.springframework.amqp.rabbit.connection.SingleConnectionFactory


    super();
  }

  @Bean
  public ConnectionFactory connectionFactory() {
    SingleConnectionFactory connectionFactory = new SingleConnectionFactory("localhost");
    connectionFactory.setUsername("guest");
    connectionFactory.setPassword("guest");
    return connectionFactory;
  }
View Full Code Here


public class MessageListenerRecoverySingleConnectionIntegrationTests extends MessageListenerRecoveryCachingConnectionIntegrationTests {

  @Override
  protected ConnectionFactory createConnectionFactory() {
    SingleConnectionFactory connectionFactory = new SingleConnectionFactory();
    connectionFactory.setHost("localhost");
    connectionFactory.setPort(BrokerTestUtils.getPort());
    return connectionFactory;
  }
View Full Code Here

    ConnectionFactory mockConnectionFactory = mock(ConnectionFactory.class);
    Connection mockConnection = mock(Connection.class);
    final Channel onlyChannel = mock(Channel.class);
    when(onlyChannel.isOpen()).thenReturn(true);

    final SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory(mockConnectionFactory);

    when(mockConnectionFactory.newConnection((ExecutorService) null)).thenReturn(mockConnection);
    when(mockConnection.isOpen()).thenReturn(true);

    final AtomicReference<Exception> tooManyChannels = new AtomicReference<Exception>();
View Full Code Here

    final Channel firstChannel = mock(Channel.class);
    when(firstChannel.isOpen()).thenReturn(true);
    final Channel secondChannel = mock(Channel.class);
    when(secondChannel.isOpen()).thenReturn(true);

    final SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory(mockConnectionFactory);

    when(mockConnectionFactory.newConnection((ExecutorService) null)).thenReturn(mockConnection);
    when(mockConnection.isOpen()).thenReturn(true);

    final AtomicReference<Exception> tooManyChannels = new AtomicReference<Exception>();
View Full Code Here

  @Rule
  public ExpectedException expectedException = ExpectedException.none();

  @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();
    assertTrue(TestUtils.getPropertyValue(container, "transactional", Boolean.class));
    container.stop();
    singleConnectionFactory.destroy();
  }
View Full Code Here

    singleConnectionFactory.destroy();
  }

  @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();
    container.stop();
    singleConnectionFactory.destroy();
  }
View Full Code Here

    singleConnectionFactory.destroy();
  }

  @Test
  public void testInconsistentAcknowledgeConfiguration() throws Exception {
    final SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory("localhost");
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(singleConnectionFactory);
    container.setMessageListener(new MessageListenerAdapter(this));
    container.setQueueNames("foo");
    container.setChannelTransacted(true);
    container.setAcknowledgeMode(AcknowledgeMode.NONE);
    expectedException.expect(IllegalStateException.class);
    container.afterPropertiesSet();
    container.stop();
    singleConnectionFactory.destroy();
  }
View Full Code Here

    singleConnectionFactory.destroy();
  }

  @Test
  public void testDefaultConsumerCount() throws Exception {
    final SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory("localhost");
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(singleConnectionFactory);
    container.setMessageListener(new MessageListenerAdapter(this));
    container.setQueueNames("foo");
    container.setAutoStartup(false);
    container.afterPropertiesSet();
    assertEquals(1, ReflectionTestUtils.getField(container, "concurrentConsumers"));
    container.stop();
    singleConnectionFactory.destroy();
  }
View Full Code Here

    singleConnectionFactory.destroy();
  }

  @Test
  public void testLazyConsumerCount() throws Exception {
    final SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory("localhost");
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(singleConnectionFactory) {
      @Override
      protected void doStart() throws Exception {
        // do nothing
      }
    };
    container.start();
    assertEquals(1, ReflectionTestUtils.getField(container, "concurrentConsumers"));
    container.stop();
    singleConnectionFactory.destroy();
  }
View Full Code Here

  static final String ROUTING_KEY = "AmqpAppenderTest.#";

  @Bean
  public SingleConnectionFactory connectionFactory() {
    return new SingleConnectionFactory("localhost");
  }
View Full Code Here

TOP

Related Classes of org.springframework.amqp.rabbit.connection.SingleConnectionFactory

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.