优化
This commit is contained in:
+2
@@ -6,6 +6,7 @@ import com.baiyue.eventbridge.domain.BridgeInbox;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.Timer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Clock;
|
||||
@@ -41,6 +42,7 @@ public class EventBridgeMetrics {
|
||||
private final MeterRegistry registry;
|
||||
private final Clock clock;
|
||||
|
||||
@Autowired
|
||||
public EventBridgeMetrics(MeterRegistry registry) {
|
||||
this(registry, Clock.systemDefaultZone());
|
||||
}
|
||||
|
||||
+8
-4
@@ -47,10 +47,14 @@ public class HttpSecurityProjectionEventClient implements SecurityProjectionEven
|
||||
JsonNode body;
|
||||
try { body = objectMapper.readTree(response.body()); }
|
||||
catch (Exception exception) { body = null; }
|
||||
if (response.statusCode() / 100 != 2 || body == null || !"200".equals(body.path("code").asText())
|
||||
|| !row.getEventId().equals(body.path("data").path("eventId").asText())) {
|
||||
throw new IllegalStateException("海外安全投影消费失败: HTTP " + response.statusCode());
|
||||
}
|
||||
requireAcknowledgement(response.statusCode(), body, row.getEventId());
|
||||
return String.valueOf(response.statusCode());
|
||||
}
|
||||
|
||||
static void requireAcknowledgement(int statusCode, JsonNode body, String eventId) {
|
||||
if (statusCode / 100 != 2 || body == null || !"200".equals(body.path("code").asText())
|
||||
|| !eventId.equals(body.path("data").path("eventId").asText())) {
|
||||
throw new IllegalStateException("Lastleg 安全投影消费失败: HTTP " + statusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user