Skip to content

Commit a373482

Browse files
committed
changes for /health and /version.
1 parent 50bbaa0 commit a373482

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/main/java/com/iemr/admin/service/health/HealthService.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import org.slf4j.Logger;
3434
import org.slf4j.LoggerFactory;
3535
import org.springframework.beans.factory.annotation.Autowired;
36+
import org.springframework.beans.factory.annotation.Value;
37+
import org.springframework.data.redis.core.RedisCallback;
3638
import org.springframework.data.redis.core.RedisTemplate;
3739
import org.springframework.stereotype.Service;
3840

@@ -45,6 +47,9 @@ public class HealthService {
4547
@Autowired
4648
private DataSource dataSource;
4749

50+
@Value("${app.version:unknown}")
51+
private String appVersion;
52+
4853
@Autowired(required = false)
4954
private RedisTemplate<String, Object> redisTemplate;
5055

@@ -78,7 +83,7 @@ public Map<String, Object> checkHealth() {
7883
healthStatus.put("services", services);
7984
healthStatus.put("timestamp", Instant.now().toString());
8085
healthStatus.put("application", "admin-api");
81-
healthStatus.put("version", "3.1.0");
86+
healthStatus.put("version", appVersion);
8287

8388
logger.info("Health check completed - Overall status: {}", overallHealth ? "UP" : "DOWN");
8489
return healthStatus;
@@ -138,8 +143,10 @@ private Map<String, Object> checkRedisHealth() {
138143
long startTime = System.currentTimeMillis();
139144

140145
try {
141-
// Test Redis connection with ping
142-
String pong = redisTemplate.getConnectionFactory().getConnection().ping();
146+
// Test Redis connection with ping using explicit RedisCallback
147+
String pong = redisTemplate.execute((RedisCallback<String>) connection -> {
148+
return connection.ping();
149+
});
143150

144151
if ("PONG".equals(pong)) {
145152
long responseTime = System.currentTimeMillis() - startTime;

0 commit comments

Comments
 (0)