Add support to time out long running queries

It's not flaky for this case (this query with this threshold in our current algorithm), the callback from EE to Java is pretty frequent for every 1 millis almost.