@Override public ErrorCondition getRemoteCondition() { return connection.getRemoteCondition(); }
@Override public void onConnectionRemoteClose(Event event) { final Connection connection = event.getConnection(); final ErrorCondition error = connection.getRemoteCondition(); if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format(Locale.US, "onConnectionRemoteClose: hostname[%s], errorCondition[%s], errorDescription[%s]", connection.getHostname(), error != null ? error.getCondition() : "n/a", error != null ? error.getDescription() : "n/a")); } this.amqpConnection.onConnectionError(error); }
@Override public void onConnectionRemoteClose(Event event) { final Connection connection = event.getConnection(); final ErrorCondition error = connection.getRemoteCondition(); TRACE_LOGGER.debug("onConnectionRemoteClose: hostname:{},errorCondition:{}", connection.getHostname(), error != null ? error.getCondition() + "," + error.getDescription() : null); boolean shouldFreeConnection = connection.getLocalState() == EndpointState.CLOSED; this.messagingFactory.onConnectionError(error); if(shouldFreeConnection) { connection.free(); } }
@Override public void processRemoteClose(AmqpProvider provider) throws IOException { getResourceInfo().setState(ResourceState.REMOTELY_CLOSED); if (isAwaitingClose()) { closeResource(provider, null, true); // Close was expected so ignore any endpoint errors. } else { Exception cause = AmqpSupport.convertToException(provider, getEndpoint(), getEndpoint().getRemoteCondition()); if (!(cause instanceof ProviderException)) { cause = new ProviderResourceClosedException(cause.getMessage(), cause); } closeResource(provider, cause, true); } }
@Override public void processRemoteClose(AmqpProvider provider) throws IOException { getResourceInfo().setState(ResourceState.REMOTELY_CLOSED); if (isAwaitingClose()) { closeResource(provider, null, true); // Close was expected so ignore any endpoint errors. } else { Exception cause = AmqpSupport.convertToException(provider, getEndpoint(), getEndpoint().getRemoteCondition()); if (!(cause instanceof ProviderException)) { cause = new ProviderResourceClosedException(cause.getMessage(), cause); } closeResource(provider, cause, true); } }
@Override public void inspectClosedResource(Connection connection) { ErrorCondition remoteError = connection.getRemoteCondition(); if (remoteError == null || remoteError.getCondition() == null) { markAsInvalid("Broker did not add error condition for duplicate client ID"); } else { if (!remoteError.getCondition().equals(AmqpError.INVALID_FIELD)) { markAsInvalid("Broker did not set condition to " + AmqpError.INVALID_FIELD); } if (!remoteError.getCondition().equals(AmqpError.INVALID_FIELD)) { markAsInvalid("Broker did not set condition to " + AmqpError.INVALID_FIELD); } } // Validate the info map contains a hint that the container/client id was the // problem Map<?, ?> infoMap = remoteError.getInfo(); if (infoMap == null) { markAsInvalid("Broker did not set an info map on condition"); } else if (!infoMap.containsKey(INVALID_FIELD)) { markAsInvalid("Info map does not contain expected key"); } else { Object value = infoMap.get(INVALID_FIELD); if (!CONTAINER_ID.equals(value)) { markAsInvalid("Info map does not contain expected value: " + value); } } } });
String receiverError = event.getReceiver() != null && event.getReceiver().getRemoteCondition() != null && event.getReceiver().getRemoteCondition().getCondition() != null ? event.getReceiver().getRemoteCondition().getCondition().toString() : ""; String sessionError = event.getSession() != null && event.getSession().getRemoteCondition() != null && event.getSession().getRemoteCondition().getCondition() != null ? event.getSession().getRemoteCondition().getCondition().toString() : ""; String connectionError = event.getConnection() != null && event.getConnection().getRemoteCondition() != null && event.getConnection().getRemoteCondition().getCondition() != null ? event.getConnection().getRemoteCondition().getCondition().toString() : ""; String linkError = event.getLink() != null && event.getLink().getRemoteCondition() != null && event.getLink().getRemoteCondition().getCondition() != null ? event.getLink().getRemoteCondition().getCondition().toString() : ""; String transportError = event.getTransport() != null && event.getTransport().getRemoteCondition() != null && event.getTransport().getRemoteCondition().getCondition() != null ? event.getTransport().getRemoteCondition().getCondition().toString() : ""; String receiverErrorDescription = event.getReceiver() != null && event.getReceiver().getRemoteCondition() != null && event.getReceiver().getRemoteCondition().getDescription() != null ? event.getReceiver().getRemoteCondition().getDescription() : ""; String sessionErrorDescription = event.getSession() != null && event.getSession().getRemoteCondition() != null && event.getSession().getRemoteCondition().getDescription() != null ? event.getSession().getRemoteCondition().getDescription() : ""; String connectionErrorDescription = event.getConnection() != null && event.getConnection().getRemoteCondition() != null && event.getConnection().getRemoteCondition().getDescription() != null ? event.getConnection().getRemoteCondition().getDescription() : ""; String linkErrorDescription = event.getLink() != null && event.getLink().getRemoteCondition() != null && event.getLink().getRemoteCondition().getDescription() != null ? event.getLink().getRemoteCondition().getDescription() : ""; String transportErrorDescription = event.getTransport() != null && event.getTransport().getRemoteCondition() != null && event.getTransport().getRemoteCondition().getDescription() != null ? event.getTransport().getRemoteCondition().getDescription() : "";
@Test(timeout = 60000) public void testCloseIsSentOnConnectionClose() throws Exception { AmqpClient client = createAmqpClient(); AmqpConnection amqpConnection = client.connect(); try { for (RemotingConnection connection : server.getRemotingService().getConnections()) { server.getRemotingService().removeConnection(connection); connection.disconnect(true); } Wait.assertTrue(amqpConnection::isClosed); assertEquals(AmqpSupport.CONNECTION_FORCED, amqpConnection.getConnection().getRemoteCondition().getCondition()); } finally { amqpConnection.close(); } }
final ErrorCondition remoteCondition = event.getConnection().getRemoteCondition(); final EngineConnection engineConnection = (EngineConnection)event.getConnection().getContext(); if (engineConnection.timerPromise != null) {