Example usage for io.vertx.pgclient PgConnection cancelRequest

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

Introduction

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

Prototype

PgConnection cancelRequest(Handler<AsyncResult<Void>> handler);

Source Link

Document

Send a request cancellation message to tell the server to cancel processing request in this connection.

Usage

From source file:examples.PgClientExamples.java

License:Apache License

public void cancelRequest(PgConnection connection) {
    connection.query("SELECT pg_sleep(20)", ar -> {
        if (ar.succeeded()) {
            // imagine this is a long query and is still running
            System.out.println("Query success");
        } else {/* w  w  w  .j  a v a2  s .  c  o m*/
            // the server will abort the current query after cancelling request
            System.out.println("Failed to query due to " + ar.cause().getMessage());
        }
    });
    connection.cancelRequest(ar -> {
        if (ar.succeeded()) {
            System.out.println("Cancelling request has been sent");
        } else {
            System.out.println("Failed to send cancelling request");
        }
    });
}