diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-07-18 09:49:06 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-07-18 09:49:06 +0200 |
commit | 316857ca9ac3b22b176f17b6e0fd9850cf077cb6 (patch) | |
tree | f8cd4480d52156977c72833aa9e74029c2caf803 /src/main/java/at | |
parent | 8bb3cdc03be4afaf6aa97cf84f3e4ea4f979c067 (diff) | |
download | moa-zs-316857ca9ac3b22b176f17b6e0fd9850cf077cb6.tar.gz moa-zs-316857ca9ac3b22b176f17b6e0fd9850cf077cb6.tar.bz2 moa-zs-316857ca9ac3b22b176f17b6e0fd9850cf077cb6.zip |
Refactor MzsService: Handle Timeouts In Separate Method
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/service/MzsService.java | 16 |
1 files 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<RequestStatusResponse> 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(); |