@Override public void start() throws Exception { ProtonServer server = ProtonServer.create(vertx); // Configure how new connections are handled server.connectHandler((connection) -> { initConnection(vertx, connection); }); server.listen(PORT, (res) -> { if (res.succeeded()) { System.out.println("Listening on port " + res.result().actualPort()); } else { System.out.println("Failed to start listening on port " + PORT + ":"); res.cause().printStackTrace(); } }); }
/** * {@inheritDoc} */ @Override protected int getActualPort() { return secureServer != null ? secureServer.actualPort() : Constants.PORT_UNCONFIGURED; }
@Override protected final int getActualInsecurePort() { return insecureServer != null ? insecureServer.actualPort() : Constants.PORT_UNCONFIGURED; }
/** * {@inheritDoc} */ @Override protected int getActualInsecurePort() { return insecureServer != null ? insecureServer.actualPort() : Constants.PORT_UNCONFIGURED; }
public int port() { if (server == null) { return 0; } return server.actualPort(); }
@Override protected final int getActualInsecurePort() { return insecureServer != null ? insecureServer.actualPort() : Constants.PORT_UNCONFIGURED; }
@Override protected final int getActualPort() { return server != null ? server.actualPort() : Constants.PORT_UNCONFIGURED; }
@Override protected final int getActualPort() { return server != null ? server.actualPort() : Constants.PORT_UNCONFIGURED; }
/** * Sets the AMQP server for handling insecure AMQP connections. * * @param server The insecure server instance. * @throws NullPointerException If the server is {@code null}. */ protected void setInsecureAmqpServer(final ProtonServer server) { Objects.requireNonNull(server); if (server.actualPort() > 0) { throw new IllegalArgumentException("AMQP Server should not be running"); } else { this.insecureServer = server; } }
/** * Gets the port Hono listens on for AMQP 1.0 connections. * <p> * If the port has been set to 0 Hono will bind to an arbitrary free port chosen by the operating system during * startup. Once Hono is up and running this method returns the <em>actual port</em> Hono has bound to. * </p> * * @return the port Hono listens on. */ public int getPort() { if (server != null) { return server.actualPort(); } else { return this.honoConfig.getPort(Constants.PORT_AMQPS); } }
public int actualPort() { return server.actualPort(); }
@Override public void start(Future<Void> startPromise) { server = ProtonServer.create(vertx); server.connectHandler(this::connectHandler); server.listen(0, result -> { if (result.succeeded()) { log.info("[{}]: Starting server on port {}", containerId, server.actualPort()); startPromise.complete(); } else { log.error("[{}]: Error starting server", containerId, result.cause()); startPromise.fail(result.cause()); } }); }
/** * Start the AMQP server * * @param startFuture */ private void bindAmqpServer(Future<Void> startFuture) { ProtonServerOptions options = this.createServerOptions(); this.server = ProtonServer.create(this.vertx, options) .connectHandler(this::processConnection) .listen(ar -> { if (ar.succeeded()) { log.info("AMQP-Kafka Bridge started and listening on port {}", ar.result().actualPort()); log.info("Kafka bootstrap servers {}", this.bridgeConfigProperties.getKafkaConfigProperties().getBootstrapServers()); this.isReady = true; this.startHealthServer(); startFuture.complete(); } else { log.error("Error starting AMQP-Kafka Bridge", ar.cause()); startFuture.fail(ar.cause()); } }); }
/** * Gets the insecure port Hono listens on for AMQP 1.0 connections (if configured). * <p> * If the port has been set to 0 Hono will bind to an arbitrary free port chosen by the operating system during * startup. Once Hono is up and running this method returns the <em>actual port</em> Hono has bound to. * </p> * * @return the insecure port Hono listens on. */ public int getInsecurePort() { if (honoConfig.isInsecurePortUnconfigured() && !honoConfig.isInsecurePortEnabled()) return Constants.PORT_UNCONFIGURED; if (insecureServer != null) { return insecureServer.actualPort(); } else { return this.honoConfig.getInsecurePort(Constants.PORT_AMQP); } }