private void sendPing(RegisterEntry moduleEntry) { final RegisterEntry entry = moduleEntry.withTime(new Date()) .withUuid(uuid) .withHealth(checker.isOk() ? Health.OK : Health.ERROR) .withStats(nonEmptyOrNull(statsChecker.stats())); try { logger.debug("Posting {} to " + apiUrl + resourcePath, JacksonUtil.serializeToJson(entry)); rest.post(apiUrl + resourcePath, JacksonUtil.serializeToJson(entry)) .join(); } catch (Exception e) { logger .warn("Failed posting {} to {}" + resourcePath, JacksonUtil.serializeToJson(entry), apiUrl); } }
@POST @Path("/schedule") @Consumes("application/json") @Produces("application/json") public void schedule(@Suspended AsyncResponse response) { ReactiveSeq.of(this).foldFuture(WorkerThreads.ioExecutor.get(), s -> s.forEach(Long.MAX_VALUE, next -> { try { job.schedule(); response.resume(HashMapBuilder.of("status", "success")); } catch (Exception e) { logger.error(e.getMessage(), e); response.resume(HashMapBuilder.of("status", "failure")); } })); }
@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); } }
@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); } }
private void sendPing(RegisterEntry moduleEntry) { final RegisterEntry entry = moduleEntry.withTime(new Date()) .withUuid(uuid) .withHealth(checker.isOk() ? Health.OK : Health.ERROR) .withStats(nonEmptyOrNull(statsChecker.stats())); try { logger.debug("Posting {} to " + apiUrl + resourcePath, JacksonUtil.serializeToJson(entry)); rest.post(apiUrl + resourcePath, JacksonUtil.serializeToJson(entry)) .join(); } catch (Exception e) { logger .warn("Failed posting {} to {}" + resourcePath, JacksonUtil.serializeToJson(entry), apiUrl); } }
@POST @Path("/schedule") @Consumes("application/json") @Produces("application/json") public void schedule(@Suspended AsyncResponse response) { ReactiveSeq.of(this).foldFuture(WorkerThreads.ioExecutor.get(), s -> s.forEach(Long.MAX_VALUE, next -> { try { job.schedule(); response.resume(HashMapBuilder.of("status", "success")); } catch (Exception e) { logger.error(e.getMessage(), e); response.resume(HashMapBuilder.of("status", "failure")); } })); }