org.springframework.amqp.rabbit.connection.Connection Java Examples
The following examples show how to use
org.springframework.amqp.rabbit.connection.Connection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RepublishUnitTests.java From spring-cloud-stream-binder-rabbit with Apache License 2.0 | 6 votes |
@Test public void testBadRepublishSetting() throws IOException { ConnectionFactory cf = mock(ConnectionFactory.class); Connection conn = mock(Connection.class); given(cf.createConnection()).willReturn(conn); Channel channel = mock(Channel.class); given(channel.isOpen()).willReturn(true); given(channel.exchangeDeclarePassive("DLX")).willThrow(new IOException()); given(conn.createChannel(false)).willReturn(channel); RabbitProperties props = new RabbitProperties(); RabbitMessageChannelBinder binder = new RabbitMessageChannelBinder(cf, props, null); RabbitConsumerProperties extension = new RabbitConsumerProperties(); ExtendedConsumerProperties<RabbitConsumerProperties> bindingProps = new ExtendedConsumerProperties<RabbitConsumerProperties>(extension); MessageHandler handler = binder.getErrorMessageHandler(mock(ConsumerDestination.class), "foo", bindingProps); ErrorMessage message = new ErrorMessage(new RuntimeException("test"), Collections.singletonMap(IntegrationMessageHeaderAccessor.SOURCE_DATA, new Message("foo".getBytes(), new MessageProperties()))); handler.handleMessage(message); handler.handleMessage(message); verify(channel, times(1)).exchangeDeclarePassive("DLX"); verify(channel, never()).basicPublish(any(), any(), eq(false), any(), any()); }
Example #2
Source File: AmqpApplication.java From rabbitmq-mock with Apache License 2.0 | 5 votes |
private static void rawConfiguration(ConnectionFactory connectionFactory) { try { // Connection & Channel may not yet implement AutoCloseable Connection connection = connectionFactory.createConnection(); Channel channel = connection.createChannel(false); channel.exchangeDeclare("xyz", "direct", true); } catch(IOException e) { throw new UncheckedIOException("Failed to declare an Exchange using Channel directly", e); } }
Example #3
Source File: RabbitSourceTestConfiguration.java From spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Bean public ConnectionFactory rabbitConnectionFactory() { ConnectionFactory mockCF = mock(ConnectionFactory.class); Connection mockConn = mock(Connection.class); when(mockCF.createConnection()).thenReturn(mockConn); Channel mockChannel = mock(Channel.class); when(mockChannel.isOpen()).thenReturn(true); when(mockConn.createChannel(anyBoolean())).thenReturn(mockChannel); return mockCF; }
Example #4
Source File: ExchangeAndQueueCreateTest.java From sinavi-jfw with Apache License 2.0 | 4 votes |
@Before public void ping() { // Ping的にコネクションのみはることでExchange/Queueを作成 Connection con = connection.createConnection(); con.createChannel(false); }
Example #5
Source File: RabbitAdapter.java From dew with Apache License 2.0 | 2 votes |
/** * Gets connection. * * @return the connection */ Connection getConnection() { return rabbitTemplate.getConnectionFactory().createConnection(); }