Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider x-timeout HTTP header upon queue item dequeuing #611

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -292,7 +293,17 @@ private void executeQueuedRequest(Message<JsonObject> message, Logger logger, Ht
performCircuitBreakerActions(queueName, queuedRequest, FAILURE, state);
});
};
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
Loading