Java Code Examples for com.rabbitmq.client.ShutdownSignalException#getReason()
The following examples show how to use
com.rabbitmq.client.ShutdownSignalException#getReason() .
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: RabbitMqIOTest.java From beam with Apache License 2.0 | 6 votes |
@Test(timeout = ONE_MINUTE_MS) public void testDeclareIncompatibleExchangeFails() throws Exception { RabbitMqIO.Read read = RabbitMqIO.read().withExchange("IncompatibleExchange", "direct", "unused"); try { doExchangeTest(new ExchangeTestPlan(read, 1), true); fail("Expected to have failed to declare an incompatible exchange"); } catch (Exception e) { Throwable cause = Throwables.getRootCause(e); if (cause instanceof ShutdownSignalException) { ShutdownSignalException sse = (ShutdownSignalException) cause; Method reason = sse.getReason(); if (reason instanceof com.rabbitmq.client.AMQP.Connection.Close) { com.rabbitmq.client.AMQP.Connection.Close close = (com.rabbitmq.client.AMQP.Connection.Close) reason; assertEquals("Expected failure is 530: not-allowed", 530, close.getReplyCode()); } else { fail( "Unexpected ShutdownSignalException reason. Expected Connection.Close. Got: " + reason); } } else { fail("Expected to fail with ShutdownSignalException. Instead failed with " + cause); } } }
Example 2
Source File: Exceptions.java From lyra with Apache License 2.0 | 5 votes |
private static boolean isRetryable(ShutdownSignalException e) { if (e.isInitiatedByApplication()) return false; Method method = e.getReason(); if (method instanceof AMQP.Connection.Close) return isRetryable(((AMQP.Connection.Close) method).getReplyCode()); if (method instanceof AMQP.Channel.Close) return isRetryable(((AMQP.Channel.Close) method).getReplyCode()); return false; }
Example 3
Source File: AbstractFunctionalTest.java From lyra with Apache License 2.0 | 5 votes |
protected void callShutdownListener(RetryableResource resource, ShutdownSignalException e) { Method method = e.getReason(); if (method instanceof AMQP.Connection.Close) { if (recoveryChannel != null) when(recoveryChannel.isOpen()).thenReturn(false); connectionHandler.shutdownListeners.get(0).shutdownCompleted(e); } else if (method instanceof AMQP.Channel.Close) resource.shutdownListeners.get(0).shutdownCompleted(e); }