This commit is contained in:
2026-08-25 16:40:48 +08:00
parent 1f6f1a0677
commit 87c5e18ca6
93 changed files with 1154 additions and 527 deletions
@@ -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());
}
@@ -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);
}
}
}