diff --git a/cameleer-server-app/src/main/java/com/cameleer/server/app/controller/AgentRegistrationController.java b/cameleer-server-app/src/main/java/com/cameleer/server/app/controller/AgentRegistrationController.java index aed8bea3..30cca8a4 100644 --- a/cameleer-server-app/src/main/java/com/cameleer/server/app/controller/AgentRegistrationController.java +++ b/cameleer-server-app/src/main/java/com/cameleer/server/app/controller/AgentRegistrationController.java @@ -257,24 +257,20 @@ public class AgentRegistrationController { } } - if (request != null && request.getRouteStates() != null && !request.getRouteStates().isEmpty()) { + if (routeIds != null && !routeIds.isEmpty()) { AgentInfo agent = registryService.findById(id); if (agent != null) { - for (var entry : request.getRouteStates().entrySet()) { - RouteStateRegistry.RouteState state = parseRouteState(entry.getValue()); - if (state != null) { - routeStateRegistry.setState(agent.applicationId(), entry.getKey(), state); + // Update route states from heartbeat + if (request != null && request.getRouteStates() != null) { + for (var entry : request.getRouteStates().entrySet()) { + RouteStateRegistry.RouteState state = parseRouteState(entry.getValue()); + if (state != null) { + routeStateRegistry.setState(agent.applicationId(), entry.getKey(), state); + } } } - } - } - - // Persist routes in catalog for server-restart recovery - if (routeIds != null && !routeIds.isEmpty()) { - AgentInfo agentForCatalog = registryService.findById(id); - if (agentForCatalog != null) { - String catalogEnv = agentForCatalog.environmentId(); - routeCatalogStore.upsert(agentForCatalog.applicationId(), catalogEnv, routeIds); + // Persist routes in catalog for server-restart recovery + routeCatalogStore.upsert(agent.applicationId(), agent.environmentId(), routeIds); } }