Skip to content

Commit

Permalink
also log the timeout being used
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-cnx committed Sep 27, 2024
1 parent 98b36e0 commit 55acf12
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.swisspush.gateleen.core.http.RequestLoggerFactory;
import org.swisspush.gateleen.core.util.Address;
import org.swisspush.gateleen.core.util.StatusCode;
import org.swisspush.gateleen.core.util.StringUtils;
import org.swisspush.gateleen.monitoring.MonitoringHandler;
import org.swisspush.gateleen.queue.expiry.ExpiryCheckHandler;
import org.swisspush.gateleen.queue.queuing.circuitbreaker.QueueCircuitBreaker;
Expand Down Expand Up @@ -293,12 +294,16 @@ private void executeQueuedRequest(Message<JsonObject> message, Logger logger, Ht
});
};

if (queuedRequest.getHeaders().get("x-timeout") != null && !queuedRequest.getHeaders().get("x-timeout").isEmpty()) {
request1.idleTimeout((long) (Long.parseLong(queuedRequest.getHeaders().get("x-timeout")) * 1.1));
} else {
request1.idleTimeout(120000); // avoids blocking other requests
long idleTimeout = 120_000;
String xTimeout = queuedRequest.getHeaders().get("x-timeout");
if (StringUtils.isNotEmpty(xTimeout)) {
// the microservice that enqueued the item has requested a specific timeout, use it instead of the default
idleTimeout = Long.parseLong(xTimeout);
}

logger.debug("performing request {} {} using idle timeout {}", queuedRequest.getMethod(), queuedRequest.getUri(), idleTimeout);
request1.idleTimeout(idleTimeout); // avoids to block the queue

if (queuedRequest.getPayload() != null) {
vertx.<Buffer>executeBlocking(() -> {
long beginEpchMs = currentTimeMillis();
Expand Down

0 comments on commit 55acf12

Please sign in to comment.