etreschenkov 2026-05-28 17:51:41 +03:00
parent 2b5a065466
commit 6b04b11e9f
6 changed files with 36 additions and 2 deletions

View file

@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.filter.OncePerRequestFilter; import org.springframework.web.filter.OncePerRequestFilter;
@ -26,7 +27,6 @@ public class RequestCachingFilter extends OncePerRequestFilter {
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
FilterChain filterChain) throws ServletException, IOException { FilterChain filterChain) throws ServletException, IOException {
CachedHttpServletRequest cachedHttpServletRequest = new CachedHttpServletRequest(request); CachedHttpServletRequest cachedHttpServletRequest = new CachedHttpServletRequest(request);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("received {} request, destination '{}', body: {}", log.debug("received {} request, destination '{}', body: {}",
request.getMethod(), request.getMethod(),
@ -37,6 +37,12 @@ public class RequestCachingFilter extends OncePerRequestFilter {
filterChain.doFilter(cachedHttpServletRequest, response); filterChain.doFilter(cachedHttpServletRequest, response);
} }
@Override
protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
return request.getServletPath().equals("/login") ||
RequestMethod.GET.name().equals(request.getMethod());
}
private static String removeWhiteSpaces(byte[] cachedPayload) { private static String removeWhiteSpaces(byte[] cachedPayload) {
if (cachedPayload == null || cachedPayload.length == 0) { if (cachedPayload == null || cachedPayload.length == 0) {
return "[empty]"; return "[empty]";

View file

@ -513,4 +513,9 @@ public class OrderCurrencyListener extends QueueConsumer implements Initializing
String digits = parts[2]; String digits = parts[2];
return Long.valueOf(digits); return Long.valueOf(digits);
} }
@Override
protected boolean isEnableRequestLogging() {
return true;
}
} }

View file

@ -97,4 +97,9 @@ public class OvernightSettingsListener extends QueueConsumer implements Initiali
log.info("updated overnight system request.id[{}]: {}/{}/{}", os.getId(), os.getCompanyId(), os.getMarket(), os.getOvernightType()); log.info("updated overnight system request.id[{}]: {}/{}/{}", os.getId(), os.getCompanyId(), os.getMarket(), os.getOvernightType());
return null; return null;
} }
@Override
protected boolean isEnableRequestLogging() {
return true;
}
} }

View file

@ -239,4 +239,9 @@ public class TaskListener extends QueueConsumer implements InitializingBean {
newReq.setComment(comment); newReq.setComment(comment);
kafkaSender.sendRequestToQueue(Consts.NOTIFICATION_NEW, newReq); kafkaSender.sendRequestToQueue(Consts.NOTIFICATION_NEW, newReq);
} }
@Override
protected boolean isEnableRequestLogging() {
return true;
}
} }

View file

@ -77,7 +77,9 @@ public class SwapOvernightOrderService {
FinalCalculationResult finalCalculationResult = swapCalculationService.calcAndEnrichSwap(SettleCode.T1, context); FinalCalculationResult finalCalculationResult = swapCalculationService.calcAndEnrichSwap(SettleCode.T1, context);
if (CurrencyCode.RUB == currency && if (CurrencyCode.RUB == currency &&
finalCalculationResult.calculationResult().sum3().compareTo(BigDecimal.ZERO) >= 0) { finalCalculationResult.calculationResult().sum3().compareTo(BigDecimal.ZERO) >= 0) {
log.warn("QuantityLot greater than zero; skip forming order currency"); log.warn("QuantityLot greater than zero :{}; skip forming order currency by registry: {}",
finalCalculationResult.calculationResult().sum3(),
registry.getId());
return; return;
} }

View file

@ -103,6 +103,8 @@ public class QueueConsumer implements AutoCloseable {
ConsumerSpecificClass<?> callback = callbacks.get(next.topic()); ConsumerSpecificClass<?> callback = callbacks.get(next.topic());
Class<?> clazz = callback.getClazz(); Class<?> clazz = callback.getClazz();
JavaType payloadType = json.getTypeFactory().constructParametricType(BaseRequest.class, clazz); JavaType payloadType = json.getTypeFactory().constructParametricType(BaseRequest.class, clazz);
String msg = (String) next.value();
loggingReq(lastTopic, msg);
o = json.readValue((String) next.value(), payloadType); o = json.readValue((String) next.value(), payloadType);
if (correlationId != null) { if (correlationId != null) {
((BaseRequest<?>) o).setCorrelationId(correlationId.value()); ((BaseRequest<?>) o).setCorrelationId(correlationId.value());
@ -210,7 +212,16 @@ public class QueueConsumer implements AutoCloseable {
return ConsumerSpecificClass.build(clazz); return ConsumerSpecificClass.build(clazz);
} }
private void loggingReq(String topic, String msg){
if (isEnableRequestLogging()) {
log.debug("Kafka message received | topic='{}' | payload={}",
topic, msg);
}
}
protected boolean isEnableRequestLogging() {
return false;
}
/** /**
* Валидация запроса * Валидация запроса
* *