Merge pull request #16 from aasaru/FINCN-180

FINCN-180 remove non-needed data source from configuration
diff --git a/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/BeatPublisherService.java b/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/BeatPublisherService.java
index 7b8bda3..32452a9 100644
--- a/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/BeatPublisherService.java
+++ b/service/src/main/java/org/apache/fineract/cn/rhythm/service/internal/service/BeatPublisherService.java
@@ -23,6 +23,8 @@
 import java.util.List;
 import java.util.Optional;
 
+import com.netflix.appinfo.InstanceInfo;
+import com.netflix.discovery.EurekaClient;
 import org.apache.fineract.cn.anubis.api.v1.domain.AllowedOperation;
 import org.apache.fineract.cn.api.context.AutoUserContext;
 import org.apache.fineract.cn.api.util.ApiFactory;
@@ -42,8 +44,6 @@
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.cloud.client.ServiceInstance;
-import org.springframework.cloud.client.discovery.DiscoveryClient;
 import org.springframework.stereotype.Service;
 
 /**
@@ -52,7 +52,7 @@
 @SuppressWarnings("WeakerAccess")
 @Service
 public class BeatPublisherService {
-  private final DiscoveryClient discoveryClient;
+  private final EurekaClient eurekaClient;
   private final ApplicationPermissionRequestCreator applicationPermissionRequestCreator;
   private final ApplicationAccessTokenService applicationAccessTokenService;
   private final ApplicationName rhythmApplicationName;
@@ -62,14 +62,14 @@
 
   @Autowired
   public BeatPublisherService(
-          @SuppressWarnings("SpringJavaAutowiringInspection") final DiscoveryClient discoveryClient,
-          @SuppressWarnings("SpringJavaAutowiringInspection") final ApplicationPermissionRequestCreator applicationPermissionRequestCreator,
-          @SuppressWarnings("SpringJavaAutowiringInspection") final ApplicationAccessTokenService applicationAccessTokenService,
-          final ApplicationName rhythmApplicationName,
-          final ApiFactory apiFactory,
-          final RhythmProperties properties,
-          @Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger) {
-    this.discoveryClient = discoveryClient;
+       @SuppressWarnings("SpringJavaAutowiringInspection") final EurekaClient eurekaClient,
+       @SuppressWarnings("SpringJavaAutowiringInspection") final ApplicationPermissionRequestCreator applicationPermissionRequestCreator,
+       @SuppressWarnings("SpringJavaAutowiringInspection") final ApplicationAccessTokenService applicationAccessTokenService,
+       final ApplicationName rhythmApplicationName,
+       final ApiFactory apiFactory,
+       final RhythmProperties properties,
+       @Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger) {
+    this.eurekaClient = eurekaClient;
     this.applicationPermissionRequestCreator = applicationPermissionRequestCreator;
     this.applicationAccessTokenService = applicationAccessTokenService;
     this.rhythmApplicationName = rhythmApplicationName;
@@ -138,12 +138,12 @@
     final BeatPublish beatPublish = new BeatPublish(beatIdentifier, DateConverter.toIsoString(timestamp));
     logger.info("Attempting publish {} with timestamp {} under user {}.", beatPublish, timestamp, properties.getUser());
 
-    final List<ServiceInstance> applicationsByName = discoveryClient.getInstances(applicationIdentifier);
+    final List<InstanceInfo> applicationsByName = eurekaClient.getApplication(applicationIdentifier).getInstances();
     if (applicationsByName.isEmpty())
       return false;
 
-    final ServiceInstance beatListenerService = applicationsByName.get(0);
-    final BeatListener beatListener = apiFactory.create(BeatListener.class, beatListenerService.getUri().toString());
+    final InstanceInfo beatListenerService = applicationsByName.get(0);
+    final BeatListener beatListener = apiFactory.create(BeatListener.class, beatListenerService.getHomePageUrl());
 
     try (final AutoTenantContext ignored = new AutoTenantContext(tenantIdentifier)) {
       final String accessToken;
@@ -163,8 +163,8 @@
       }
     }
     catch (final Throwable e) {
-      logger.warn("Unable to publish beat '{}' to application '{}' for tenant '{}', " +
-              "because exception was thrown in publish.", beatIdentifier, applicationIdentifier, tenantIdentifier, e);
+      logger.warn("Unable to publish beat '{}' to application '{}' (uri: '{}') for tenant '{}' with user '{}'" +
+              "because exception was thrown in publish", beatIdentifier, applicationIdentifier,beatListenerService.getHomePageUrl(), tenantIdentifier, properties.getUser(), e);
       return false;
     }
   }
diff --git a/service/src/main/resources/application.yml b/service/src/main/resources/application.yml
index f33393a..9a58954 100644
--- a/service/src/main/resources/application.yml
+++ b/service/src/main/resources/application.yml
@@ -23,17 +23,13 @@
       enabled: false
     config:
       enabled: false
-  datasource:
-    driver-class-name: org.postgresql.Driver
-    platform: postgres
-    url: jdbc:postgresql://localhost:5432/seshat
-    username: postgres
-    password: postgres
 
 eureka:
   application:
     serviceUrl:
       defaultZone: http://localhost:8761/eureka/
+  instance:
+    homePageUrl: "http://${eureka.hostname}:2022/rhythm/v1/"
 
 server:
   port: 2022
diff --git a/shared.gradle b/shared.gradle
index d0b6b57..381632b 100644
--- a/shared.gradle
+++ b/shared.gradle
@@ -85,7 +85,7 @@
         }
     }
 }
-artifactoryPublish.dependsOn('clean','publishToMavenLocal')
+artifactoryPublish.dependsOn('publishToMavenLocal')
 
 license {
     header rootProject.file('../HEADER')