Example usage for io.vertx.pgclient.pubsub PgSubscriber reconnectPolicy

List of usage examples for io.vertx.pgclient.pubsub PgSubscriber reconnectPolicy

Introduction

In this page you can find the example usage for io.vertx.pgclient.pubsub PgSubscriber reconnectPolicy.

Prototype

@Fluent
PgSubscriber reconnectPolicy(Function<Integer, Long> policy);

Source Link

Document

Set the reconnect policy that is executed when the subscriber is disconnected.

Usage

From source file:examples.PgClientExamples.java

License:Apache License

public void pubsub04(Vertx vertx) {

    PgSubscriber subscriber = PgSubscriber.subscriber(vertx, new PgConnectOptions().setPort(5432)
            .setHost("the-host").setDatabase("the-db").setUser("user").setPassword("secret"));

    // Reconnect at most 10 times after 100 ms each
    subscriber.reconnectPolicy(retries -> {
        if (retries < 10) {
            return 100L;
        } else {/* w w w  .j ava  2  s .  c  o  m*/
            return -1L;
        }
    });
}