@Override public void close() { synchronized (lock) { connection.close(); } flush(); }
@Override public ProtonConnection close() { connection.close(); flush(); return this; }
@Override protected void afterOpened() { getEndpoint().close(); }
@Override protected void afterOpened() { getEndpoint().close(); }
@Override public void onOpenComplete(Exception exception) { if (exception == null) { this.open.complete(this); // if connection creation is in progress and then msgFactory.close call came thru if (this.getIsClosingOrClosed()) this.connection.close(); } else { this.open.completeExceptionally(exception); } if (this.openTimer != null) this.openTimer.cancel(false); }
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(); }
@Override public void onResponse(AmqpProtocolConverter converter, Response response) throws IOException { protonConnection.close(); protonConnection.free(); if (!closedSocket) { pumpProtonToSocket(); } } });
@Override public void onResponse(AmqpProtocolConverter converter, Response response) throws IOException { protonConnection.close(); protonConnection.free(); if (!closedSocket) { pumpProtonToSocket(); } } });
@Override public void onRemoteClose(Connection connection) { handler.requireHandler(); connection.close(); connection.free(); for (AMQPSessionContext protonSession : sessions.values()) { protonSession.close(); } sessions.clear(); // We must force write the channel before we actually destroy the connection handler.flushBytes(); destroy(); }
@Override public void onRemoteClose(Connection connection) { synchronized (getLock()) { connection.close(); for (AbstractProtonSessionContext protonSession : sessions.values()) { protonSession.close(); } sessions.clear(); } // We must force write the channel before we actually destroy the connection onTransport(handler.getTransport()); destroy(); }
@Override public void onRemoteClose(Connection connection) { lock(); try { connection.close(); connection.free(); } finally { unlock(); } for (AMQPSessionContext protonSession : sessions.values()) { protonSession.close(); } sessions.clear(); // We must force write the channel before we actually destroy the connection handler.flushBytes(); destroy(); }
@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) { } } }
private void closeAsync() { // Codes_SRS_AMQPSIOTHUBCONNECTION_15_048 [If the AMQPS connection is already closed, the function shall do nothing.] // Codes_SRS_AMQPSIOTHUBCONNECTION_15_012: [The function shall set the status of the AMQPS connection to CLOSED.] this.state = State.CLOSED; // Codes_SRS_AMQPSIOTHUBCONNECTION_15_013: [The function shall close the AMQPS sender and receiver links, // the AMQPS session and the AMQPS connection.] if (this.sender != null) this.sender.close(); if (this.receiver != null) this.receiver.close(); if (this.session != null) this.session.close(); if (this.connection != null) this.connection.close(); // Codes_SRS_AMQPSIOTHUBCONNECTION_15_014: [The function shall stop the Proton reactor.] this.reactor.stop(); }
@Override public void onRemoteOpen(Connection connection) throws Exception { handler.requireHandler(); try { initInternal(); } catch (Exception e) { log.error("Error init connection", e); } if (!validateConnection(connection)) { connection.close(); } else { connection.setContext(AMQPConnectionContext.this); connection.setContainer(containerId); connection.setProperties(connectionProperties); connection.setOfferedCapabilities(getConnectionCapabilitiesOffered()); connection.open(); } initialise(); /* * This can be null which is in effect an empty map, also we really don't need to check this for in bound connections * but its here in case we add support for outbound connections. * */ if (connection.getRemoteProperties() == null || !connection.getRemoteProperties().containsKey(CONNECTION_OPEN_FAILED)) { long nextKeepAliveTime = handler.tick(true); if (nextKeepAliveTime != 0 && scheduledPool != null) { scheduledPool.schedule(new ScheduleRunnable(), (nextKeepAliveTime - TimeUnit.NANOSECONDS.toMillis(System.nanoTime())), TimeUnit.MILLISECONDS); } } }
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(); }); }
@Override public void onDelivery(Event event) { //Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_023: [ The event handler shall get the Delivery from the event only if the event type is DELIVERY **]** if(event.getType() == Event.Type.DELIVERY) { // Codes_SRS_AMQPSIOTHUBCONNECTION_15_038: [If this link is the Sender link and the event type is DELIVERY, the event handler shall get the Delivery (Proton) object from the event.] Delivery d = event.getDelivery(); //Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_024: [ The event handler shall get the Delivery remote state from the delivery **]** DeliveryState remoteState = d.getRemoteState(); //Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_025: [ The event handler shall verify the Amqp response and add the response to a queue. **]** sendStatusQueue.add(new AmqpResponseVerification(remoteState)); //Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_026: [ The event handler shall settle the delivery. **]** d.settle(); //Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_027: [ The event handler shall get the Sender (Proton) object from the event **]** Sender snd = event.getSender(); //Codes_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_028: [ The event handler shall close the Sender, Session and Connection **]** snd.close(); snd.getSession().close(); snd.getSession().getConnection().close(); isConnected = false; } }
/** * Private helper for close. * Closes the AmqpsSessionManager, the connection and stops the Proton reactor. */ private void closeAsync() { logger.LogDebug("Entered in method %s", logger.getMethodName()); // Codes_SRS_AMQPSIOTHUBCONNECTION_15_012: [The function shall set the status of the AMQPS connection to DISCONNECTED.] this.state = IotHubConnectionStatus.DISCONNECTED; // Codes_SRS_AMQPSIOTHUBCONNECTION_15_013: [The function shall closeNow the AmqpsSessionManager and the AMQP connection.] this.amqpsSessionManager.closeNow(); if (this.connection != null) { this.connection.close(); } // Codes_SRS_AMQPSIOTHUBCONNECTION_34_014: [If this object's proton reactor is not null, this function shall stop the Proton reactor.] if (this.reactor != null) { this.reactor.stop(); } logger.LogInfo("Proton reactor has been stopped, method name is %s ", logger.getMethodName()); logger.LogDebug("Exited from method %s", logger.getMethodName()); }
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); }