From 316857ca9ac3b22b176f17b6e0fd9850cf077cb6 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Thu, 18 Jul 2019 09:49:06 +0200 Subject: Refactor MzsService: Handle Timeouts In Separate Method --- src/main/java/at/gv/egiz/moazs/service/MzsService.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/gv/egiz/moazs/service/MzsService.java b/src/main/java/at/gv/egiz/moazs/service/MzsService.java index d48f668..77027a9 100644 --- a/src/main/java/at/gv/egiz/moazs/service/MzsService.java +++ b/src/main/java/at/gv/egiz/moazs/service/MzsService.java @@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.jws.WebParam; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Consumer; @@ -78,10 +79,7 @@ public class MzsService implements App2MzsPortType { return converter.convert(status, binaryStatus); } catch (TimeoutException e) { - logger.info(format(SERVICE_TIME_OUT_REACHED_MSG, appDeliveryID), e); - var sinkParams = completeRequest.getConfig().getMsgResponseSinks(); - requestProcessed.thenAcceptAsync(response -> hub.applySinks(response, sinkParams)); - return generatePartialSuccessResponse(appDeliveryID); + return handleAssyncStatus(appDeliveryID, completeRequest, requestProcessed); } catch (Exception e) { var message = format(MZS_SERVICE_ERROR_MSG, appDeliveryID); @@ -90,6 +88,16 @@ public class MzsService implements App2MzsPortType { } + private DeliveryResponseType handleAssyncStatus(String appDeliveryID, DeliveryRequestType request, + CompletableFuture requestProcessed) { + + logger.info(format(SERVICE_TIME_OUT_REACHED_MSG, appDeliveryID)); + var sinkParams = request.getConfig().getMsgResponseSinks(); + requestProcessed.thenAcceptAsync(response -> hub.applySinks(response, sinkParams)); + + return generatePartialSuccessResponse(appDeliveryID); + } + private RequestStatusResponse process(DeliveryRequestType deliveryRequest) { var appDeliveryID = deliveryRequest.getMetaData().getAppDeliveryID(); -- cgit v1.2.3