diff --git a/jbpm-wb-kie-server/jbpm-wb-kie-server-backend/src/main/java/org/jbpm/workbench/ks/integration/KieServerIntegration.java b/jbpm-wb-kie-server/jbpm-wb-kie-server-backend/src/main/java/org/jbpm/workbench/ks/integration/KieServerIntegration.java index d2df73c818..390e30152c 100644 --- a/jbpm-wb-kie-server/jbpm-wb-kie-server-backend/src/main/java/org/jbpm/workbench/ks/integration/KieServerIntegration.java +++ b/jbpm-wb-kie-server/jbpm-wb-kie-server-backend/src/main/java/org/jbpm/workbench/ks/integration/KieServerIntegration.java @@ -245,30 +245,42 @@ public void onServerInstanceDisconnected(@Observes ServerInstanceDisconnected se public void onServerInstanceConnected(@Observes ServerInstanceConnected serverInstanceConnected) { ServerInstance serverInstance = serverInstanceConnected.getServerInstance(); - serverTemplatesClients.computeIfPresent(serverInstance.getServerTemplateId(), - (serverTemplateId, clients) -> { - clients.forEach((key, client) -> { - // update regular clients - updateOrBuildClient(client, - serverInstance); - - logger.debug("KieServerClient load balancer updated for server template {}", - serverTemplateId.equals(SERVER_TEMPLATE_KEY) ? serverInstance.getServerTemplateId() : serverTemplateId); - }); - return clients; - }); - serverInstancesById.put(serverInstance.getServerInstanceId(), - serverInstance); + if (serverInstancesById.containsKey(serverInstance.getServerInstanceId())) { + // If Server is already connected do not proceed with Artifacts Build + logger.info("Server {} already registered", serverInstance); + logger.info("Skipping build of containers"); + } + else { + logger.info("Server {} connected!", serverInstance); + + serverInstancesById.put(serverInstance.getServerInstanceId(), serverInstance); + + buildClientsForServer(serverInstance); + + KieServicesClient adminClient = adminClients.get(serverInstance.getServerTemplateId()); + // update admin clients + updateOrBuildClient(adminClient, serverInstance); + } + - KieServicesClient adminClient = adminClients.get(serverInstance.getServerTemplateId()); - // update admin clients - updateOrBuildClient(adminClient, - serverInstance); // once all steps are completed successfully notify other parts interested so the serverClient can actually be used serverInstanceRegisteredEvent.fire(new ServerInstanceRegistered(serverInstanceConnected.getServerInstance())); } + private void buildClientsForServer(final ServerInstance serverInstance) { + serverTemplatesClients.computeIfPresent(serverInstance.getServerTemplateId(), (serverTemplateId, clients) -> { + clients.forEach((key, client) -> { + // update regular clients + updateOrBuildClient(client, serverInstance); + + logger.debug("KieServerClient load balancer updated for server template {}", + serverTemplateId.equals(SERVER_TEMPLATE_KEY) ? serverInstance.getServerTemplateId() : serverTemplateId); + }); + return clients; + }); + } + public List broadcastToKieServers(String serverTemplateId, Function operation) { List results = new ArrayList<>();