Explorar el Código

修改线程数

yumeng hace 6 días
padre
commit
244c9fac0d

+ 7 - 7
src/main/java/com/adx/tencent/honor/HonorTrackingController.java

@@ -12,7 +12,6 @@ import org.slf4j.LoggerFactory;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.HttpStatus;
 import org.springframework.lang.Nullable;
 import org.springframework.lang.Nullable;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.ResponseStatus;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.server.ResponseStatusException;
 import org.springframework.web.server.ResponseStatusException;
 
 
@@ -46,11 +45,10 @@ public class HonorTrackingController {
     }
     }
 
 
     @GetMapping("/honor/impression")
     @GetMapping("/honor/impression")
-    @ResponseStatus(HttpStatus.NO_CONTENT)
-    public void impression(HttpServletRequest request) throws Exception {
+    public Object impression(HttpServletRequest request) throws Exception {
         impressionSemaphore.acquire();
         impressionSemaphore.acquire();
         try {
         try {
-            doImpression(request);
+            return doImpression(request);
         } finally {
         } finally {
             impressionSemaphore.release();
             impressionSemaphore.release();
         }
         }
@@ -66,7 +64,7 @@ public class HonorTrackingController {
         }
         }
     }
     }
 
 
-    private void doImpression(HttpServletRequest request) throws Exception {
+    private Object doImpression(HttpServletRequest request) throws Exception {
         if (placement == null) throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "honor placement not configured");
         if (placement == null) throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "honor placement not configured");
         Map<String, String> params = normalizeParams(request);
         Map<String, String> params = normalizeParams(request);
         String tagId = requireTagId(params);
         String tagId = requireTagId(params);
@@ -81,10 +79,12 @@ public class HonorTrackingController {
         HonorBidRecord record = bidRecordFromResponse(response, traceId, "impression", params);
         HonorBidRecord record = bidRecordFromResponse(response, traceId, "impression", params);
         hotStore.recordBid(record);
         hotStore.recordBid(record);
 
 
+        List<TrackingResult> tracking = Collections.emptyList();
         if (response.getBid() != null && response.getBid().getShowUrls() != null && !response.getBid().getShowUrls().isEmpty()) {
         if (response.getBid() != null && response.getBid().getShowUrls() != null && !response.getBid().getShowUrls().isEmpty()) {
-            List<TrackingResult> tracking = adxClient.reportImpression(response.getBid().getShowUrls(), response.getBid().getPrice());
+            tracking = adxClient.reportImpression(response.getBid().getShowUrls(), response.getBid().getPrice());
             recordTracking(record.getQk(), tagId, "impression", tracking);
             recordTracking(record.getQk(), tagId, "impression", tracking);
         }
         }
+        return Map.of("qk", record.getQk(), "traceId", traceId, "tagId", tagId);
     }
     }
 
 
     private Object doClick(HttpServletRequest request, HttpServletResponse response) throws Exception {
     private Object doClick(HttpServletRequest request, HttpServletResponse response) throws Exception {
@@ -120,7 +120,7 @@ public class HonorTrackingController {
             response.sendRedirect(destination);
             response.sendRedirect(destination);
             return null;
             return null;
         }
         }
-        return Map.of("qk", record.getQk(), "traceId", traceId, "tagId", tagId, "tracking", tracking);
+        return Map.of("qk", record.getQk(), "traceId", traceId, "tagId", tagId);
     }
     }
 
 
     private Map<String, Object> buildBidRequest(HttpServletRequest request, String traceId, Map<String, String> params) {
     private Map<String, Object> buildBidRequest(HttpServletRequest request, String traceId, Map<String, String> params) {

+ 5 - 5
src/main/java/com/adx/tencent/httpapi/TrackingController.java

@@ -62,17 +62,16 @@ public class TrackingController {
      * 限制最多50个线程同时执行。
      * 限制最多50个线程同时执行。
      */
      */
     @GetMapping("/tencent/impression")
     @GetMapping("/tencent/impression")
-    @ResponseStatus(HttpStatus.NO_CONTENT)
-    public void tencentImpression(HttpServletRequest request) throws Exception {
+    public Object tencentImpression(HttpServletRequest request) throws Exception {
         impressionSemaphore.acquire();
         impressionSemaphore.acquire();
         try {
         try {
-            doImpression(request);
+            return doImpression(request);
         } finally {
         } finally {
             impressionSemaphore.release();
             impressionSemaphore.release();
         }
         }
     }
     }
 
 
-    private void doImpression(HttpServletRequest request) throws Exception {
+    private Object doImpression(HttpServletRequest request) throws Exception {
         Map<String, String> params = flatQueryParams(request);
         Map<String, String> params = flatQueryParams(request);
         String traceId = mediaTraceId(params);
         String traceId = mediaTraceId(params);
         if (traceId == null || traceId.isBlank()) {
         if (traceId == null || traceId.isBlank()) {
@@ -110,6 +109,7 @@ public class TrackingController {
             log.info("[impression] 曝光上报完成, qk={}, results={}", response.getQk(), trackingResults);
             log.info("[impression] 曝光上报完成, qk={}, results={}", response.getQk(), trackingResults);
             recordTrackingResults(response.getQk(), "impression", trackingResults);
             recordTrackingResults(response.getQk(), "impression", trackingResults);
         }
         }
+        return Map.of("qk", nvl(record.getQk()), "traceId", traceId);
     }
     }
 
 
     // ─── GET /tencent/click ──────────────────────────────────────────────────
     // ─── GET /tencent/click ──────────────────────────────────────────────────
@@ -193,7 +193,7 @@ public class TrackingController {
             return null;
             return null;
         }
         }
 
 
-        return Map.of("qk", nvl(record.getQk()), "traceId", traceId, "tracking", trackingResults);
+        return Map.of("qk", nvl(record.getQk()), "traceId", traceId);
     }
     }
 
 
     // ─── 私有工具方法 ────────────────────────────────────────────────────────
     // ─── 私有工具方法 ────────────────────────────────────────────────────────