public EndpointState getLocalState() { return session.getLocalState(); }
@Override public void onSessionRemoteOpen(Event e) { if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format(Locale.US, "onSessionRemoteOpen entityName[%s], sessionIncCapacity[%s], sessionOutgoingWindow[%s]", this.entityName, e.getSession().getIncomingCapacity(), e.getSession().getOutgoingWindow())); } final Session session = e.getSession(); if (session != null && session.getLocalState() == EndpointState.UNINITIALIZED) { session.open(); } sessionCreated = true; if (this.onRemoteSessionOpen != null) this.onRemoteSessionOpen.accept(session); }
private void closeSession(Link link, ErrorCondition condition) { final Session session = link.getSession(); if (session != null && session.getLocalState() != EndpointState.CLOSED) { if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format("closeSession for linkName[%s], errorCondition[%s], errorDescription[%s]", link.getName(), condition != null ? condition.getCondition() : "n/a", condition != null ? condition.getDescription() : "n/a")); } session.setCondition(condition); session.close(); } }
private void closeSession(Link link) { if (link.getSession() != null && link.getSession().getLocalState() != EndpointState.CLOSED) link.getSession().close(); } }
@Override public void onSessionRemoteOpen(Event e) { TRACE_LOGGER.debug("onSessionRemoteOpen - entityName: {}, sessionIncCapacity: {}, sessionOutgoingWindow: {}", this.name, e.getSession().getIncomingCapacity(), e.getSession().getOutgoingWindow()); Session session = e.getSession(); if (session != null && session.getLocalState() == EndpointState.UNINITIALIZED) { session.open(); } }
@Override public void onSessionRemoteClose(Event e) { if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format(Locale.US, "onSessionRemoteClose entityName[%s], condition[%s]", this.entityName, e.getSession().getRemoteCondition() == null ? "none" : e.getSession().getRemoteCondition().toString())); } final Session session = e.getSession(); ErrorCondition condition = session != null ? session.getRemoteCondition() : null; if (session != null && session.getLocalState() != EndpointState.CLOSED) { if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format(Locale.US, "onSessionRemoteClose closing a local session for entityName[%s], condition[%s], description[%s]", this.entityName, condition != null ? condition.getCondition() : "n/a", condition != null ? condition.getDescription() : "n/a")); } session.setCondition(session.getRemoteCondition()); session.close(); } this.sessionOpenErrorDispatched = true; if (!sessionCreated && this.onRemoteSessionOpenError != null) this.onRemoteSessionOpenError.accept(condition, null); }
@Override public void onSessionRemoteClose(Event e) { TRACE_LOGGER.debug("onSessionRemoteClose - entityName: {}, condition: {}", this.name, e.getSession().getCondition() == null ? "none" : e.getSession().getCondition().toString()); Session session = e.getSession(); if (session != null && session.getLocalState() != EndpointState.CLOSED) { session.close(); } }
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); }