io.vertx.core.eventbus.EventBusOptions Java Examples

The following examples show how to use io.vertx.core.eventbus.EventBusOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Gateway.java    From vertx-in-action with MIT License 6 votes vote down vote up
public static void main(String[] args) throws UnknownHostException {
  String ipv4 = InetAddress.getLocalHost().getHostAddress();
  VertxOptions options = new VertxOptions()
    .setEventBusOptions(new EventBusOptions()
      .setHost(ipv4)
      .setClusterPublicHost(ipv4))
    .setMetricsOptions(new MicrometerMetricsOptions()
      .setPrometheusOptions(new VertxPrometheusOptions()
        .setPublishQuantiles(true)
        .setEnabled(true))
      .setEnabled(true));
  Vertx.clusteredVertx(options, ar -> {
    if (ar.succeeded()) {
      ar.result().deployVerticle(new Gateway());
    } else {
      logger.error("Could not start", ar.cause());
    }
  });
}
 
Example #2
Source File: HeatSensor.java    From vertx-in-action with MIT License 5 votes vote down vote up
public static void main(String[] args) throws UnknownHostException {
  String ipv4 = InetAddress.getLocalHost().getHostAddress();
  VertxOptions options = new VertxOptions()
    .setEventBusOptions(new EventBusOptions()
      .setHost(ipv4)
      .setClusterPublicHost(ipv4));
  Vertx.clusteredVertx(options, ar -> {
    if (ar.succeeded()) {
      ar.result().deployVerticle(new HeatSensor());
    } else {
      logger.error("Could not start", ar.cause());
    }
  });
}
 
Example #3
Source File: VertxCoreRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private static void setEventBusOptions(VertxConfiguration conf, VertxOptions options) {
    EventBusConfiguration eb = conf.eventbus;
    EventBusOptions opts = new EventBusOptions();
    opts.setAcceptBacklog(eb.acceptBacklog.orElse(-1));
    opts.setClientAuth(ClientAuth.valueOf(eb.clientAuth.toUpperCase()));
    opts.setConnectTimeout((int) (Math.min(Integer.MAX_VALUE, eb.connectTimeout.toMillis())));
    // todo: use timeUnit cleverly
    opts.setIdleTimeout(
            eb.idleTimeout.isPresent() ? (int) Math.max(1, Math.min(Integer.MAX_VALUE, eb.idleTimeout.get().getSeconds()))
                    : 0);
    opts.setSendBufferSize(eb.sendBufferSize.orElse(-1));
    opts.setSoLinger(eb.soLinger.orElse(-1));
    opts.setSsl(eb.ssl);
    opts.setReceiveBufferSize(eb.receiveBufferSize.orElse(-1));
    opts.setReconnectAttempts(eb.reconnectAttempts);
    opts.setReconnectInterval(eb.reconnectInterval.toMillis());
    opts.setReuseAddress(eb.reuseAddress);
    opts.setReusePort(eb.reusePort);
    opts.setTrafficClass(eb.trafficClass.orElse(-1));
    opts.setTcpKeepAlive(eb.tcpKeepAlive);
    opts.setTcpNoDelay(eb.tcpNoDelay);
    opts.setTrustAll(eb.trustAll);

    // Certificates and trust.
    configurePemKeyCertOptions(opts, eb.keyCertificatePem);
    configureJksKeyCertOptions(opts, eb.keyCertificateJks);
    configurePfxKeyCertOptions(opts, eb.keyCertificatePfx);

    configurePemTrustOptions(opts, eb.trustCertificatePem);
    configureJksKeyCertOptions(opts, eb.trustCertificateJks);
    configurePfxTrustOptions(opts, eb.trustCertificatePfx);

    options.setEventBusOptions(opts);
}
 
Example #4
Source File: MainDeploy.java    From okapi with Apache License 2.0 5 votes vote down vote up
private void deployClustered(final Logger logger, Handler<AsyncResult<Vertx>> fut) {
  if (hazelcastConfig == null) {
    hazelcastConfig = ConfigUtil.loadConfig();
    if (clusterHost != null) {
      NetworkConfig network = hazelcastConfig.getNetworkConfig();
      InterfacesConfig interfacesConfig = network.getInterfaces();
      interfacesConfig.setEnabled(true).addInterface(clusterHost);
    }
  }
  hazelcastConfig.setProperty("hazelcast.logging.type", "log4j");

  HazelcastClusterManager mgr = new HazelcastClusterManager(hazelcastConfig);
  vopt.setClusterManager(mgr);
  EventBusOptions eventBusOptions = vopt.getEventBusOptions();
  if (clusterHost != null) {
    logger.info("clusterHost={}", clusterHost);
    eventBusOptions.setHost(clusterHost);
  } else {
    logger.warn("clusterHost not set");
  }
  if (clusterPort != -1) {
    logger.info("clusterPort={}", clusterPort);
    eventBusOptions.setPort(clusterPort);
  } else {
    logger.warn("clusterPort not set");
  }
  eventBusOptions.setClustered(true);

  Vertx.clusteredVertx(vopt, res -> {
    if (res.succeeded()) {
      MainVerticle v = new MainVerticle();
      v.setClusterManager(mgr);
      deploy(v, res.result(), fut);
    } else {
      fut.handle(Future.failedFuture(res.cause()));
    }
  });
}
 
Example #5
Source File: VertxSubstitutions.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Substitute
private int getClusterPublicPort(EventBusOptions options, int actualPort) {
    throw new RuntimeException("Not Implemented");
}
 
Example #6
Source File: VertxSubstitutions.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Substitute
private String getClusterPublicHost(EventBusOptions options) {
    throw new RuntimeException("Not Implemented");
}
 
Example #7
Source File: VertxSubstitutions.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Substitute
EventBusOptions options() {
    throw new RuntimeException("Not Implemented");
}