Vertx Circuit breaker with timeout - cancel future if not processed in time

353 views
Skip to first unread message

AndWlf

unread,
Jun 13, 2017, 11:53:02 AM6/13/17
to vert.x
Hi,

I have a specific situation in my project that would require to have the ability to cancel the work of a worker-thread after a given time.

Depending on the user input, the processing takes very long. Given that the backend should give an answer in a specified amount of time, I will answer the client with an error (using eventBus  replyHandler). Meanwhile, the worker thread will continue working on the complex input for a long time, consuming resources to produce an output that will not be used.

I tried using vertx-circuit-breaker (3.3.3 and 3.4.0) with a timeout. The timer is fired (early in a multi-threading setup), the operation is counted as failed, but the processing of the future is not canceled.

Is there any way to stop a worker-thread to do work that is no longer needed?

Thanks!




Jez P

unread,
Jun 13, 2017, 1:18:58 PM6/13/17
to vert.x
It's pretty much impossible to guarantee killing a thread. Not a vert.x limitation, but fundamentally a Java one. This came up recently on the forum. If you can make your processing interruptible, maybe you could have your own signal to the thread to interrupt your processing. 

Jez P

unread,
Jun 13, 2017, 1:20:29 PM6/13/17
to vert.x

AndWlf

unread,
Jun 13, 2017, 1:28:48 PM6/13/17
to vert.x
Thanks. I didn't come around that topic before.
Reply all
Reply to author
Forward
0 new messages