aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-18 09:49:06 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-18 09:49:06 +0200
commit316857ca9ac3b22b176f17b6e0fd9850cf077cb6 (patch)
treef8cd4480d52156977c72833aa9e74029c2caf803
parent8bb3cdc03be4afaf6aa97cf84f3e4ea4f979c067 (diff)
downloadmoa-zs-316857ca9ac3b22b176f17b6e0fd9850cf077cb6.tar.gz
moa-zs-316857ca9ac3b22b176f17b6e0fd9850cf077cb6.tar.bz2
moa-zs-316857ca9ac3b22b176f17b6e0fd9850cf077cb6.zip
Refactor MzsService: Handle Timeouts In Separate Method
-rw-r--r--src/main/java/at/gv/egiz/moazs/service/MzsService.java16
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();