Example usage for io.vertx.pgclient PgConnection notificationHandler

List of usage examples for io.vertx.pgclient PgConnection notificationHandler

Introduction

In this page you can find the example usage for io.vertx.pgclient PgConnection notificationHandler.

Prototype

@Fluent
PgConnection notificationHandler(Handler<PgNotification> handler);

Source Link

Document

Set an handler called when the connection receives notification on a channel.

Usage

From source file:examples.PgClientExamples.java

License:Apache License

public void pubsub01(PgConnection connection) {

    connection.notificationHandler(notification -> {
        System.out//from w w w  . j  a va 2s  . c  om
                .println("Received " + notification.getPayload() + " on channel " + notification.getChannel());
    });

    connection.query("LISTEN some-channel", ar -> {
        System.out.println("Subscribed to channel");
    });
}