private static void initConnection(Vertx vertx, ProtonConnection connection) { connection.openHandler(res -> { System.out.println("Client connection opened, container-id: " + connection.getRemoteContainer()); connection.open(); }); connection.closeHandler(c -> { System.out.println("Client closing connection, container-id: " + connection.getRemoteContainer()); connection.close(); connection.disconnect(); }); connection.disconnectHandler(c -> { System.out.println("Client socket disconnected, container-id: " + connection.getRemoteContainer()); connection.disconnect(); }); connection.sessionOpenHandler(session -> { session.closeHandler(x -> { session.close(); session.free(); }); session.open(); }); connection.senderOpenHandler(sender -> { initSender(vertx, connection, sender); }); connection.receiverOpenHandler(receiver -> { initReceiver(receiver); }); connection.open(); }
/** * Invoked when a client initiates a session (which is then opened in this method). * <p> * Subclasses should override this method if other behaviour shall be implemented on session open. * * @param con The connection of the session. * @param session The session that is initiated. */ protected void handleSessionOpen(final ProtonConnection con, final ProtonSession session) { LOG.debug("opening new session with client [container: {}]", con.getRemoteContainer()); session.open(); }
/** * Handler for session closing from the remote * * @param session related Proton session closed */ private void processOpenSession(ProtonSession session) { session.closeHandler(ar -> { if (ar.succeeded()) { ar.result().close(); } }).open(); }
/** * Sets a default handler on a session that is invoked when an AMQP <em>end</em> frame * is received from the peer. * <p> * The default handler sends an <em>end</em> frame and then frees up the resources * maintained for the session by invoking its <em>free</em> method. * * @param session The session to set the handler on. * @throws NullPointerException if session is {@code null}. */ public static void setDefaultCloseHandler(final ProtonSession session) { session.closeHandler(remoteClose -> { session.close(); session.free(); }); }
private ProtonSession getDefaultSession() { if (defaultSession == null) { defaultSession = createSession(); defaultSession.closeHandler(result -> { String msg = "The connections default session closed unexpectedly"; if (!result.succeeded()) { msg += ": "; msg += ": " + String.valueOf(result.cause()); } Future<ProtonConnection> failure = Future.failedFuture(msg); Handler<AsyncResult<ProtonConnection>> connCloseHandler = closeHandler; if (connCloseHandler != null) { connCloseHandler.handle(failure); } }); defaultSession.open(); // Deliberately not flushing, the sender/receiver open // call will do that (if it doesn't happen otherwise). } return defaultSession; }
private void newSession(final ProtonConnection con, final Handler<AsyncResult<ProtonSession>> sessionOpenHandler) { con.createSession().openHandler(sessionOpenHandler).open(); }
/** * This method is called when an AMQP BEGIN frame is received from a remote client. This method sets the incoming * capacity in its BEGIN Frame to be communicated to the remote peer * */ private void handleSessionOpen(final ProtonConnection conn, final ProtonSession session) { LOG.debug("opening new session with client [container: {}, session window size: {}]", conn.getRemoteContainer(), getConfig().getMaxSessionWindowSize()); session.setIncomingCapacity(getConfig().getMaxSessionWindowSize()); session.open(); }
@Override public ProtonSender createSender(String address) { return getDefaultSession().createSender(address); }
/** * Invoked when a client initiates a session (which is then opened in this method). * <p> * Subclasses should override this method if other behaviour shall be implemented on session open. * * @param con The connection of the session. * @param session The session that is initiated. */ protected void handleSessionOpen(final ProtonConnection con, final ProtonSession session) { LOG.debug("opening new session with client [container: {}]", con.getRemoteContainer()); session.open(); }
private void handleSessionOpen(final ProtonConnection con, final ProtonSession session) { LOG.info("opening new session with client [{}]", con.getRemoteContainer()); session.closeHandler(sessionResult -> { if (sessionResult.succeeded()) { sessionResult.result().close(); } }).open(); }
/** * Sets a default handler on a session that is invoked when an AMQP <em>end</em> frame * is received from the peer. * <p> * The default handler sends an <em>end</em> frame and then frees up the resources * maintained for the session by invoking its <em>free</em> method. * * @param session The session to set the handler on. * @throws NullPointerException if session is {@code null}. */ public static void setDefaultCloseHandler(final ProtonSession session) { session.closeHandler(remoteClose -> { session.close(); session.free(); }); }
@Override public ProtonSender createSender(String address, ProtonLinkOptions senderOptions) { return getDefaultSession().createSender(address, senderOptions); }
/** * Open the endpoint, opening the connection */ public void open() { this.connection .sessionOpenHandler(session -> session.open()) .open(); }
final Future<ProtonSender> result) { ProtonSender sender = session.createSender(address); sender.setQoS(qos); sender.sendQueueDrainHandler(sendQueueDrainHandler);
/** * Open the endpoint, opening the connection */ public void open() { if ((this.willHandler == null) || (this.disconnectionHandler == null)) { throw new IllegalStateException("Handlers for received will and disconnection must be set"); } this.connection .sessionOpenHandler(session -> session.open()) .receiverOpenHandler(this::receiverHandler) .open(); }
}); serverConnection.sessionOpenHandler(serverSession -> { serverSession.open(); }); serverConnection.receiverOpenHandler(serverReceiver -> {
serverSession.open(); });
serverSession.open(); });
serverSession.open(); });
serverSession.open(); });