Closing JDBC Client Connection

89 views
Skip to first unread message

Danny

unread,
Apr 29, 2021, 4:34:30 PM4/29/21
to vert.x
Hello!

I'm trying to close all DB connections when a certain event is registered. The verticle running this flow is later undeployed, so all DB connections do eventually get closed, but it seems they have to wait for the asynchronous responses. This is vertx version 3.5.0.

This is the basic setup:

futureForMyEvent.setHandler(result -> {
   connection.close(closed -> {
          log.info("Closed db connection");
    });
    connection.close();
});

connection.query(sql, result -> {
   try/catch/finally. 
   the finally closes the connection 
});

So after the query statement, and before its response, I'm triggering that event to happen manually. 

What ends up happening is that the future handler immediately executes, but the connection close handler doesn't execute yet. Like this:
  1. query sent
  2. event triggered/future completed
  3. future handler runs 
  4. Undeploy begins
  5. time passes
  6. query result returns/the finally block closes the connection
  7. connection close handler runs
  8. Undeploy finishes
Is there a way to kill the connection outright? Or maybe a way to cancel any asynchronous requests? I don't care for the response in the case of this event. 

Thanks!!
Danny







Thomas SEGISMONT

unread,
Apr 30, 2021, 4:17:26 AM4/30/21
to vert.x
Hi,
If the connection has pending operations, they will be executed before the close operation.
That could be the reason for the delay you observe.
Best regards

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/7ec57e63-40b1-4c6b-9461-966705a68c93n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages