@PostConstruct @Scheduled(fixedDelayString = "${service.registry.delay:1000}") public synchronized void schedule() { try { if (app.getApplication() != null && apiUrl != null) { app.getApplication() .forEach(moduleEntry -> sendPing(moduleEntry)); } } catch (Exception e) { logger.error("Failed to register services due to exception {}", e.getMessage(), e); } }
@Test public void testRegister() { ServerData data1 = new ServerData(8080, new ArrayList<>(), null, "url", () -> ""); ServerData data2 = new ServerData(8080, new ArrayList<>(), null, "url", () -> ""); ServerData data3 = new ServerData(8080, new ArrayList<>(), null, "url", () -> ""); List<ServerData> datas = Arrays.asList(data1, data2, data3); applicationRegister = new ApplicationRegisterImpl(); ServerData[] dataArray = new ServerData[datas.size()]; applicationRegister.register(datas.toArray(dataArray)); applicationRegister.getApplication().forEach(it -> count++); assertThat(count, is(3)); } }
@PostConstruct @Scheduled(fixedDelayString = "${service.registry.delay:1000}") public synchronized void schedule() { try { if (app.getApplication() != null && apiUrl != null) { app.getApplication() .forEach(moduleEntry -> sendPing(moduleEntry)); } } catch (Exception e) { logger.error("Failed to register services due to exception {}", e.getMessage(), e); } }