gateway-api добавил логи в GatewayController

This commit is contained in:
AKurakin 2024-07-05 11:56:39 +03:00
parent 26d6c68734
commit de3eb66799
6 changed files with 56 additions and 9 deletions

View file

@ -39,6 +39,7 @@ import ru.spcex.clearing.gatewayapi.service.processor.ListingFondProcessor;
import ru.spcex.clearing.gatewayapi.service.processor.ListingMMProcessor;
import ru.spcex.platform.utils.enumeration.EnumMessage;
import ru.spcex.platform.utils.enumeration.IMessageResolver;
import ru.spcex.platform.utils.log.ExceptionUtils;
@Controller
@RequestMapping("/")
@ -92,7 +93,13 @@ public class GatewayController {
@ResponseBody
public CommonResponse listingsFond(@RequestBody FondListingsRequest request) {
// request.validate(validTypes, List.of(Section.FOND));
executor.submit(() -> listingFondProcessor.process(request));
executor.submit(() -> {
try {
listingFondProcessor.process(request);
} catch (Throwable e) {
log.error("At process /listing_fond has error: {}", ExceptionUtils.getStackTrace(e));
}
});
return createResponse(request, true);
}
@ -111,7 +118,13 @@ public class GatewayController {
@ResponseBody
public CommonResponse listingsMM(@RequestBody MMListingsRequest request) {
// request.validate(validTypes, List.of(Section.MKR));
executor.submit(() -> listingMMProcessor.process(request));
executor.submit(() -> {
try {
listingMMProcessor.process(request);
} catch (Throwable e) {
log.error("At process /listing_mm has error: {}", ExceptionUtils.getStackTrace(e));
}
});
return createResponse(request, true);
}
@ -130,7 +143,13 @@ public class GatewayController {
@ResponseBody
public CommonResponse listingsCurr(@RequestBody CurrListingsRequest request) {
// request.validate(validTypes, List.of(Section.CURR));
executor.submit(() -> listingCurrProcessor.process(request));
executor.submit(() -> {
try {
listingCurrProcessor.process(request);
} catch (Throwable e) {
log.error("At process /listing_curr has error: {}", ExceptionUtils.getStackTrace(e));
}
});
return createResponse(request, true);
}
@ -149,7 +168,13 @@ public class GatewayController {
@ResponseBody
public CommonResponse companies(@RequestBody CompaniesRequest request) {
// request.validate(validTypes, Collections.emptyList());
executor.submit(() -> companiesProcessor.process(request));
executor.submit(() -> {
try {
companiesProcessor.process(request);
} catch (Throwable e) {
log.error("At process /companies has error: {}", ExceptionUtils.getStackTrace(e));
}
});
return createResponse(request, true);
}
@ -167,7 +192,13 @@ public class GatewayController {
@ResponseBody
public CommonResponse limits(@RequestBody LimitRequest request) {
log.debug("Received message: {}", request);
executor.submit(() -> notificationService.sendLimitNotification(request));
executor.submit(() -> {
try {
notificationService.sendLimitNotification(request);
} catch (Throwable e) {
log.error("At process /limits has error: {}", ExceptionUtils.getStackTrace(e));
}
});
return createCommonResponse(request.getId());
}
@ -185,8 +216,12 @@ public class GatewayController {
public CommonResponse operations(@RequestBody OperationsRequest request) {
log.debug("Received message: {}", request);
executor.submit(() -> {
operationService.checkAssetsAndSendMessage(request);
notificationService.sendToJournal(request);
try {
operationService.checkAssetsAndSendMessage(request);
notificationService.sendToJournal(request);
} catch (Throwable e) {
log.error("At process /operations has error: {}", ExceptionUtils.getStackTrace(e));
}
});
return createCommonResponse(request.getId());
}
@ -205,8 +240,12 @@ public class GatewayController {
public CommonResponse requestTkr(@RequestBody TkrRequest request) {
log.debug("Received message: {}", request);
executor.submit(() -> {
tkrService.processedTkrRequest(request);
notificationService.sendToJournal(request);
try {
tkrService.processedTkrRequest(request);
notificationService.sendToJournal(request);
} catch (Throwable e) {
log.error("At process /member_request_tkr has error: {}", ExceptionUtils.getStackTrace(e));
}
});
return createCommonResponse(request.getId());
}

View file

@ -104,6 +104,7 @@ public class NotificationService {
log.warn("GatewayResult by requestId = {} not found in map", request.getId().toString());
return;
}
log.debug("Update gatewayResult.id={} by requestId={}", gatewayResult.getId(), request.getId());
gatewayResult.setUpdated(Instant.now());
gatewayResult.setGatewayResultStatus(resultStatus.getKey());
String res = LogFormatter.toString(request);

View file

@ -72,6 +72,7 @@ public class CompanyProcessor {
log.error("{}", ExceptionUtils.getStackTrace(e));
}
}
log.debug("process CompaniesRequest done");
}
private <T extends WithCompanyId> List<T> groupByCompanyId(List<T> listToProcess, UUID companyId) {

View file

@ -66,5 +66,6 @@ public class ListingCurrProcessor {
log.error("currencyInstrumentId={}: {}", currencyInstrumentId, ExceptionUtils.getStackTrace(e));
}
}
log.debug("process CurrListingsRequest done");
}
}

View file

@ -1,5 +1,7 @@
package ru.spcex.clearing.gatewayapi.service.processor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import ru.spcex.clearing.gatewayapi.controller.inbound.request.listing.fond.FondListingsRequest;
import ru.spcex.clearing.gatewayapi.service.IssueCompanyService;
@ -7,6 +9,7 @@ import ru.spcex.clearing.gatewayapi.service.SecurityService;
@Service
public class ListingFondProcessor {
private final Logger log = LoggerFactory.getLogger(getClass());
private final IssueCompanyService issueCompanyProcessor;
private final SecurityService securityService;
@ -18,5 +21,6 @@ public class ListingFondProcessor {
public void process(FondListingsRequest request) {
issueCompanyProcessor.sendRequest(request);
securityService.sendRequest(request);
log.debug("process FondListingsRequest done");
}
}

View file

@ -58,5 +58,6 @@ public class ListingMMProcessor {
log.error("{}", ExceptionUtils.getStackTrace(e));
}
}
log.debug("process MMListingsRequest done");
}
}