This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 86216f92c171cce1c4ecef111658a1c7a9d58659
Author: lburgazzoli <lburgazz...@gmail.com>
AuthorDate: Mon May 28 13:38:55 2018 +0200

    CAMEL-12502: camel cloud : create a service route policy
---
 .../impl/cloud/ServiceRegistrationRoutePolicy.java | 38 ++++++++++++----------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git 
a/camel-core/src/main/java/org/apache/camel/impl/cloud/ServiceRegistrationRoutePolicy.java
 
b/camel-core/src/main/java/org/apache/camel/impl/cloud/ServiceRegistrationRoutePolicy.java
index 130b513..54dd8ba 100644
--- 
a/camel-core/src/main/java/org/apache/camel/impl/cloud/ServiceRegistrationRoutePolicy.java
+++ 
b/camel-core/src/main/java/org/apache/camel/impl/cloud/ServiceRegistrationRoutePolicy.java
@@ -146,19 +146,6 @@ public class ServiceRegistrationRoutePolicy extends 
RoutePolicySupport implement
             properties.put(key, val);
         }
 
-        // try to get the service id from route properties
-        String serviceId = properties.get(ServiceDefinition.SERVICE_META_ID);
-        if (serviceId == null) {
-            // if not check if the route id is custom and use it
-            if (route.getRouteContext().getRoute().hasCustomIdAssigned()) {
-                serviceId = route.getId();
-            }
-        }
-        if (serviceId == null) {
-            // finally get the id from the DiscoverableService
-            serviceId = properties.get(ServiceDefinition.SERVICE_META_ID);
-        }
-
         // try to get the service name from route properties
         String serviceName = 
properties.get(ServiceDefinition.SERVICE_META_NAME);
         if (serviceName == null) {
@@ -170,13 +157,30 @@ public class ServiceRegistrationRoutePolicy extends 
RoutePolicySupport implement
             serviceName = properties.get(ServiceDefinition.SERVICE_META_NAME);
         }
 
-        if (ObjectHelper.isEmpty(serviceId) || 
ObjectHelper.isEmpty(serviceName)) {
-            LOGGER.debug("Route {} has not enough information for service 
registration");
+        if (ObjectHelper.isEmpty(serviceName)) {
+            LOGGER.debug("Route {} has not enough information for service 
registration", route);
             return Optional.empty();
         }
 
-        String serviceHost = 
properties.get(ServiceDefinition.SERVICE_META_HOST);
-        String servicePort = 
properties.getOrDefault(ServiceDefinition.SERVICE_META_PORT, "-1");
+        // try to get the service id from route properties
+        String serviceId = properties.get(ServiceDefinition.SERVICE_META_ID);
+        if (serviceId == null) {
+            // if not check if the route id is custom and use it
+            if (route.getRouteContext().getRoute().hasCustomIdAssigned()) {
+                serviceId = route.getId();
+            }
+        }
+        if (serviceId == null) {
+            // then get the id from the DiscoverableService
+            serviceId = properties.get(ServiceDefinition.SERVICE_META_ID);
+        }
+        if (serviceId == null) {
+            // finally auto generate the service id
+            serviceId = getCamelContext().getUuidGenerator().generateUuid();
+        }
+
+        final String serviceHost = 
properties.get(ServiceDefinition.SERVICE_META_HOST);
+        final String servicePort = 
properties.getOrDefault(ServiceDefinition.SERVICE_META_PORT, "-1");
 
         // Build the final resource definition from bits collected from the
         // endpoint and the route.

-- 
To stop receiving notification emails like this one, please contact
lburgazz...@apache.org.

Reply via email to