@Override public ProtonConnectionImpl setCondition(ErrorCondition condition) { connection.setCondition(condition); return this; }
public void close(ErrorCondition errorCondition) { lock.lock(); try { if (errorCondition != null) { connection.setCondition(errorCondition); } connection.close(); } finally { lock.unlock(); } flush(); }
private void internalHandlerError(Exception e) { log.warn(e.getMessage(), e); ErrorCondition error = new ErrorCondition(); error.setCondition(AmqpError.INTERNAL_ERROR); error.setDescription("Unrecoverable error: " + (e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage())); connection.setCondition(error); connection.close(); flush(); }
private void dispatch() { Event ev; // We don't hold a lock on the entire event processing // because we could have a distributed deadlock // while processing events (for instance onTransport) // while a client is also trying to write here while ((ev = popEvent()) != null) { for (EventHandler h : handlers) { if (log.isTraceEnabled()) { log.trace("Handling " + ev + " towards " + h); } try { Events.dispatch(ev, h); } catch (Exception e) { log.warn(e.getMessage(), e); connection.setCondition(new ErrorCondition()); } } } for (EventHandler h : handlers) { try { h.onTransport(transport); } catch (Exception e) { log.warn(e.getMessage(), e); connection.setCondition(new ErrorCondition()); } } }
log.warn(e.getMessage(), e); transport.close(); connection.setCondition(new ErrorCondition());
@Override public long tick(boolean firstTick) { if (!firstTick) { try { if (connection.getLocalState() != EndpointState.CLOSED) { long rescheduleAt = transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); if (transport.isClosed()) { throw new IllegalStateException("Channel was inactive for to long"); } return rescheduleAt; } } catch (Exception e) { transport.close(); connection.setCondition(new ErrorCondition()); } return 0; } return transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); }
public Long tick(boolean firstTick) { requireHandler(); if (!firstTick) { try { if (connection.getLocalState() != EndpointState.CLOSED) { long rescheduleAt = transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); if (transport.isClosed()) { throw new IllegalStateException("Channel was inactive for to long"); } return rescheduleAt; } } catch (Exception e) { log.warn(e.getMessage(), e); transport.close(); connection.setCondition(new ErrorCondition()); } finally { flush(); } return 0L; } return transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); }
error.setCondition(AmqpError.INTERNAL_ERROR); error.setDescription("Unrecoverable error: " + (e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage())); connection.setCondition(error); connection.close();
error.setDescription("Unrecoverable error: " + (e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage())); connection.setCondition(error); connection.close();
@Override public void onAMQPException(IOException error) { closedSocket = true; if (!closing) { try { closing = true; // Attempt to inform the other end that we are going to close // so that the client doesn't wait around forever. protonConnection.setCondition(new ErrorCondition(AmqpError.DECODE_ERROR, error.getMessage())); protonConnection.close(); pumpProtonToSocket(); } catch (Exception ignore) { } amqpTransport.sendToActiveMQ(error); } else { try { amqpTransport.stop(); } catch (Exception ignore) { } } }
@Override public void onAMQPException(IOException error) { closedSocket = true; if (!closing) { try { closing = true; // Attempt to inform the other end that we are going to close // so that the client doesn't wait around forever. protonConnection.setCondition(new ErrorCondition(AmqpError.DECODE_ERROR, error.getMessage())); protonConnection.close(); pumpProtonToSocket(); } catch (Exception ignore) { } amqpTransport.sendToActiveMQ(error); } else { try { amqpTransport.stop(); } catch (Exception ignore) { } } }
oldConnection.setCondition(error); oldConnection.close();
oldConnection.setCondition(errorCondition); oldConnection.close();
protonConnection.setCondition(new ErrorCondition(AmqpError.UNAUTHORIZED_ACCESS, exception.getMessage())); } else if (exception instanceof InvalidClientIDException) { ErrorCondition condition = new ErrorCondition(AmqpError.INVALID_FIELD, exception.getMessage()); condition.setInfo(infoMap); protonConnection.setCondition(condition); } else { protonConnection.setCondition(new ErrorCondition(AmqpError.ILLEGAL_STATE, exception.getMessage()));
protonConnection.setCondition(new ErrorCondition(AmqpError.UNAUTHORIZED_ACCESS, exception.getMessage())); } else if (exception instanceof InvalidClientIDException) { ErrorCondition condition = new ErrorCondition(AmqpError.INVALID_FIELD, exception.getMessage()); condition.setInfo(infoMap); protonConnection.setCondition(condition); } else { protonConnection.setCondition(new ErrorCondition(AmqpError.ILLEGAL_STATE, exception.getMessage()));
public void close(ErrorCondition errorCondition, AMQPConnectionContext connectionContext) { runNow(() -> { if (errorCondition != null) { connection.setCondition(errorCondition); } connection.close(); flush(); }); /*try { Thread.sleep(1000); } catch (Exception e) { e.printStackTrace(); } */ // this needs to be done in two steps // we first flush what we have to the client // after flushed, we close the local connection // otherwise this could close the netty connection before the Writable is complete runLater(() -> { connectionContext.getConnectionCallback().getTransportConnection().close(); }); }
protonConnection.setCondition(new ErrorCondition(AmqpError.PRECONDITION_FAILED, "Cannot send idle frames")); protonConnection.close(); pumpProtonToSocket();
protonConnection.setCondition(new ErrorCondition(AmqpError.PRECONDITION_FAILED, "Cannot send idle frames")); protonConnection.close(); pumpProtonToSocket();
private void processEventSessionRemoteState(Event event) { final String methodName = "processEventSessionRemoteState"; logger.entry(this, methodName, event); if (event.getSession().getRemoteState() == EndpointState.ACTIVE) { if (event.getSession().getLocalState() == EndpointState.ACTIVE) { final EngineConnection engineConnection = (EngineConnection) event.getConnection().getContext(); if (!engineConnection.closed) { // First session has opened on the connection OpenRequest req = engineConnection.openRequest; engineConnection.openRequest = null; engineConnection.requestor.tell(new OpenResponse(req, engineConnection), this); } } else { // The remote end is trying to establish a new session with us, which is not allowed. I don't think this is a usual case, // but could occur with a badly written remote end (i.e. sends an initial AMQP open immediately followed by a begin) final Connection protonConnection = event.getConnection(); protonConnection.setCondition(new ErrorCondition(Symbol.getSymbol("mqlight:session-remote-open-rejected"), "MQ Light client is unable to accept an open session request")); protonConnection.close(); } } logger.exit(this, methodName); }