camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nferr...@apache.org
Subject [1/2] camel git commit: CAMEL-11456: Make the camel-grpc component more cloud service friendly
Date Tue, 27 Jun 2017 12:55:33 GMT
Repository: camel
Updated Branches:
  refs/heads/master 010fef2b4 -> f0e4266f2


CAMEL-11456: Make the camel-grpc component more cloud service friendly

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d20dda74
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d20dda74
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d20dda74

Branch: refs/heads/master
Commit: d20dda74a224a340d25c838b0f938d4d84f30240
Parents: 2993c51
Author: Dmitry Volodin <dmvolod@gmail.com>
Authored: Mon Jun 26 20:20:59 2017 +0300
Committer: Dmitry Volodin <dmvolod@gmail.com>
Committed: Tue Jun 27 13:13:51 2017 +0300

----------------------------------------------------------------------
 .../src/main/docs/grpc-component.adoc           | 23 +++----
 .../camel/component/grpc/GrpcComponent.java     | 29 ++++----
 .../camel/component/grpc/GrpcConfiguration.java | 71 +++++++-------------
 .../camel/component/grpc/GrpcConsumer.java      |  9 +--
 .../camel/component/grpc/GrpcEndpoint.java      | 24 ++++++-
 .../camel/component/grpc/GrpcProducer.java      | 11 ++-
 .../apache/camel/component/grpc/GrpcUtils.java  | 20 +++++-
 .../grpc/GrpcConsumerAggregationTest.java       |  4 +-
 .../grpc/GrpcConsumerConcurrentTest.java        |  4 +-
 .../grpc/GrpcConsumerPropagationTest.java       |  4 +-
 .../component/grpc/GrpcProducerAsyncTest.java   | 10 +--
 .../grpc/GrpcProducerStreamingTest.java         |  9 ++-
 .../component/grpc/GrpcProducerSyncTest.java    | 17 ++---
 .../camel-grpc/src/test/proto/pingpong.proto    |  2 +-
 14 files changed, 115 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/main/docs/grpc-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/docs/grpc-component.adoc b/components/camel-grpc/src/main/docs/grpc-component.adoc
index 95820de..0bea6aa 100644
--- a/components/camel-grpc/src/main/docs/grpc-component.adoc
+++ b/components/camel-grpc/src/main/docs/grpc-component.adoc
@@ -35,27 +35,27 @@ The gRPC component has no options.
 // endpoint options: START
 The gRPC endpoint is configured using URI syntax:
 
-    grpc:service
+    grpc:host:port/service
 
 with the following path and query parameters:
 
-#### Path Parameters (1 parameters):
+#### Path Parameters (3 parameters):
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |=======================================================================
 | Name | Description | Default | Type
+| **host** | *Required* The gRPC server host name. This is localhost or 0.0.0.0 when being
a consumer or remote server hostname when using producer. |  | String
+| **port** | *Required* The gRPC server port |  | int
 | **service** | *Required* Fully qualified service name from the protocol buffer descriptor
file (package dot service definition name) |  | String
 |=======================================================================
 
-#### Query Parameters (14 parameters):
+#### Query Parameters (11 parameters):
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |=======================================================================
 | Name | Description | Default | Type
 | **forwardOnCompleted** (common) | Determines if onCompleted events should be pushed to
the Camel route. | false | boolean
 | **forwardOnError** (common) | Determines if onError events should be pushed to the Camel
route. Exceptions will be set as message body. | false | boolean
-| **host** (common) | The gRPC server host name |  | String
-| **port** (common) | The gRPC server port |  | int
 | **bridgeErrorHandler** (consumer) | Allows for bridging the consumer to the Camel routing
Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming
messages or the likes will now be processed as a message and handled by the routing Error
Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal
with exceptions that will be logged at WARN or ERROR level and ignored. | false | boolean
 | **consumerStrategy** (consumer) | This option specifies the top-level strategy for processing
service requests and responses in streaming mode. If an aggregation strategy is selected all
requests will be accumulated in the list then transferred to the flow and the accumulated
responses will be sent to the sender. If a propagation strategy is selected request is sent
to the stream and the response will be immediately sent back to the sender. | PROPAGATION
| GrpcConsumerStrategy
 | **exceptionHandler** (consumer) | To let the consumer use a custom ExceptionHandler. Notice
if the option bridgeErrorHandler is enabled then this options is not in use. By default the
consumer will deal with exceptions that will be logged at WARN or ERROR level and ignored.
|  | ExceptionHandler
@@ -63,7 +63,6 @@ with the following path and query parameters:
 | **method** (producer) | gRPC method name |  | String
 | **producerStrategy** (producer) | The mode used to communicate with a remote gRPC server.
In SIMPLE mode a single exchange is translated into a remote procedure call. In STREAMING
mode all exchanges will be sent within the same request (input and output of the recipient
gRPC service must be of type 'stream'). | SIMPLE | GrpcProducerStrategy
 | **streamRepliesTo** (producer) | When using STREAMING client mode it indicates the endpoint
where responses should be forwarded. |  | String
-| **target** (producer) | The channel target name as alternative to host and port parameters
|  | String
 | **usePlainText** (producer) | The plain text connection to the server flag | true | Boolean
 | **synchronous** (advanced) | Sets whether synchronous processing should be strictly used
or Camel is allowed to use asynchronous processing (if supported). | false | boolean
 |=======================================================================
@@ -108,30 +107,30 @@ Below is a simple synchronous method invoke with host and port parameters
 [source,java]
 -------------------------------------------------------------------------------
 from("direct:grpc-sync")
-.to("grpc://org.apache.camel.component.grpc.PingPong?method=sendPing&host=localhost&port=1000&synchronous=true");
+.to("grpc://remotehost:1101/org.apache.camel.component.grpc.PingPong?method=sendPing&synchronous=true");
 -------------------------------------------------------------------------------
 
 [source,java]
 ---------------------------------------------------------------------------------------
 <route>
     <from uri="direct:grpc-sync" />
-    <to uri="grpc://org.apache.camel.component.grpc.PingPong?method=sendPing&host=localhost&port=1000&synchronous=true"/>
+    <to uri="grpc://remotehost:1101/org.apache.camel.component.grpc.PingPong?method=sendPing&synchronous=true"/>
 </route>
 ---------------------------------------------------------------------------------------
 
-An asynchronous method invoke with target host and port parameter
+An asynchronous method invoke
 
 [source,java]
 -------------------------------------------------------------------------------
 from("direct:grpc-async")
-.to("grpc://org.apache.camel.component.grpc.PingPong?method=pingAsyncResponse&target=dns:///hostname:8000");
+.to("grpc://remotehost:1101/org.apache.camel.component.grpc.PingPong?method=pingAsyncResponse");
 -------------------------------------------------------------------------------
 
 gRPC service consumer with propagation consumer strategy
 
 [source,java]
 -------------------------------------------------------------------------------
-from("grpc://org.apache.camel.component.grpc.PingPong?consumerStrategy=PROPAGATION&host=localhost&port=1000")
+from("grpc://localhost:1101/org.apache.camel.component.grpc.PingPong?consumerStrategy=PROPAGATION")
 .to("direct:grpc-service");
 -------------------------------------------------------------------------------
 
@@ -140,7 +139,7 @@ gRPC service producer with streaming producer strategy (requires a service
that
 [source,java]
 -------------------------------------------------------------------------------
 from("direct:grpc-request-stream")
-.to("grpc://org.apache.camel.component.grpc.PingPong?method=PingAsyncAsync&producerStrategy=STREAMING&streamRepliesTo=direct:grpc-response-stream&target=dns:///hostname:8000");
+.to("grpc://remotehost:1101/org.apache.camel.component.grpc.PingPong?method=PingAsyncAsync&producerStrategy=STREAMING&streamRepliesTo=direct:grpc-response-stream");
 
 from("direct:grpc-response-stream")
 .log("Response received: ${body}");

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcComponent.java
b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcComponent.java
index b5a6a6a..1473734 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcComponent.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcComponent.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.grpc;
 
+import java.net.URI;
 import java.util.Map;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.DefaultComponent;
-import org.apache.camel.util.ObjectHelper;
 
 /**
  * Represents the component that manages {@link GrpcEndpoint}.
@@ -29,26 +29,21 @@ public class GrpcComponent extends DefaultComponent {
 
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
         GrpcConfiguration config = new GrpcConfiguration();
+        
+        config = parseConfiguration(config, uri, parameters);
         setProperties(config, parameters);
 
-        // Extract service and package names from the full service name
-        config.setServiceName(extractServiceName(remaining));
-        config.setServicePackage(extractServicePackage(remaining));
-        // Convert method name to the camel case style
-        // This requires if method name as described inside .proto file directly
-        if (!ObjectHelper.isEmpty(config.getMethod())) {
-            config.setMethod(GrpcUtils.convertMethod2CamelCase(config.getMethod()));
-        }
-
         Endpoint endpoint = new GrpcEndpoint(uri, this, config);
         return endpoint;
     }
-
-    private String extractServiceName(String service) {
-        return service.substring(service.lastIndexOf(".") + 1);
-    }
-
-    private String extractServicePackage(String service) {
-        return service.substring(0, service.lastIndexOf("."));
+    
+    /**
+     * Parses the configuration
+     * 
+     * @return the parsed and valid configuration to use
+     */
+    protected GrpcConfiguration parseConfiguration(GrpcConfiguration configuration, String
remaining, Map<String, Object> parameters) throws Exception {
+        configuration.parseURI(new URI(remaining), parameters, this);
+        return configuration;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
index 3a708d8..74e011c 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConfiguration.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.grpc;
 
+import java.net.URI;
+import java.util.Map;
+
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
@@ -26,20 +29,19 @@ public class GrpcConfiguration {
 
     @UriPath
     @Metadata(required = "true")
-    private String service;
-    
-    @UriParam(label = "producer")
-    private String method;
-    
-    @UriParam
     private String host;
-    
-    @UriParam
+
+    @UriPath
+    @Metadata(required = "true")
     private int port;
     
-    @UriParam(label = "producer")
-    private String target;
+    @UriPath
+    @Metadata(required = "true")
+    private String service;
     
+    @UriParam(label = "producer")
+    private String method;
+            
     @UriParam(label = "producer", defaultValue = "true")
     private Boolean usePlainText = true;
 
@@ -59,9 +61,6 @@ public class GrpcConfiguration {
     @UriParam(defaultValue = "false")
     private boolean forwardOnError;
 
-    private String serviceName;
-    private String servicePackage;
-
     /**
      * Fully qualified service name from the protocol buffer descriptor file
      * (package dot service definition name)
@@ -86,7 +85,8 @@ public class GrpcConfiguration {
     }
 
     /**
-     * The gRPC server host name
+     * The gRPC server host name. This is localhost or 0.0.0.0 when being a
+     * consumer or remote server hostname when using producer.
      */
     public String getHost() {
         return host;
@@ -108,17 +108,6 @@ public class GrpcConfiguration {
     }
 
     /**
-     * The channel target name as alternative to host and port parameters
-     */
-    public String getTarget() {
-        return target;
-    }
-
-    public void setTarget(String target) {
-        this.target = target;
-    }
-
-    /**
      * The plain text connection to the server flag
      */
     public Boolean getUsePlainText() {
@@ -168,28 +157,6 @@ public class GrpcConfiguration {
         return forwardOnError;
     }
 
-    /**
-     * The service name extracted from the full service name
-     */
-    protected String getServiceName() {
-        return serviceName;
-    }
-
-    protected void setServiceName(String serviceName) {
-        this.serviceName = serviceName;
-    }
-
-    /**
-     * The service package name extracted from the full service name
-     */
-    protected String getServicePackage() {
-        return servicePackage;
-    }
-
-    protected void setServicePackage(String servicePackage) {
-        this.servicePackage = servicePackage;
-    }
-
     public GrpcProducerStrategy getProducerStrategy() {
         return producerStrategy;
     }
@@ -213,4 +180,14 @@ public class GrpcConfiguration {
     public void setStreamRepliesTo(String streamRepliesTo) {
         this.streamRepliesTo = streamRepliesTo;
     }
+    
+    public void parseURI(URI uri, Map<String, Object> parameters, GrpcComponent component)
{
+        setHost(uri.getHost());
+        
+        if (uri.getPort() != -1) {
+            setPort(uri.getPort());
+        }
+        
+        setService(uri.getPath().substring(1));
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConsumer.java
b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConsumer.java
index 7b69c96..f92525b 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConsumer.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcConsumer.java
@@ -64,7 +64,7 @@ public class GrpcConsumer extends DefaultConsumer {
             LOG.info("Starting the gRPC server");
             initializeServer();
             server.start();
-            LOG.info("gRPC server started and listening on port: " + server.getPort());
+            LOG.info("gRPC server started and listening on port: {}", server.getPort());
         }
     }
 
@@ -85,7 +85,7 @@ public class GrpcConsumer extends DefaultConsumer {
         ServerInterceptor headerInterceptor = new GrpcHeaderInterceptor();
         MethodHandler methodHandler = new GrpcMethodHandler(endpoint, this);
         
-        serviceProxy.setSuperclass(GrpcUtils.constructGrpcImplBaseClass(configuration.getServicePackage(),
configuration.getServiceName(), endpoint.getCamelContext()));
+        serviceProxy.setSuperclass(GrpcUtils.constructGrpcImplBaseClass(endpoint.getServicePackage(),
endpoint.getServiceName(), endpoint.getCamelContext()));
         try {
             bindableService = (BindableService)serviceProxy.create(new Class<?>[0],
new Object[0], methodHandler);
         } catch (NoSuchMethodException | IllegalArgumentException | InstantiationException
| IllegalAccessException | InvocationTargetException e) {
@@ -93,11 +93,8 @@ public class GrpcConsumer extends DefaultConsumer {
         }
         
         if (!ObjectHelper.isEmpty(configuration.getHost()) && !ObjectHelper.isEmpty(configuration.getPort()))
{
-            LOG.debug("Building gRPC server on " + configuration.getHost() + ":" + configuration.getPort());
+            LOG.debug("Building gRPC server on {}:{}", configuration.getHost(), configuration.getPort());
             serverBuilder = NettyServerBuilder.forAddress(new InetSocketAddress(configuration.getHost(),
configuration.getPort()));
-        } else if (ObjectHelper.isEmpty(configuration.getHost()) && !ObjectHelper.isEmpty(configuration.getPort()))
{
-            LOG.debug("Building gRPC server on <any address>" + ":" + configuration.getPort());
-            serverBuilder = NettyServerBuilder.forPort(configuration.getPort());
         } else {
             throw new IllegalArgumentException("No server start properties (host, port) specified");
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcEndpoint.java
b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcEndpoint.java
index 1f6010c..8c8c3cc 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcEndpoint.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcEndpoint.java
@@ -23,18 +23,32 @@ import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.impl.SynchronousDelegateProducer;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * The gRPC component allows to call and expose remote procedures via HTTP/2 with protobuf
dataformat
  */
-@UriEndpoint(firstVersion = "2.19.0", scheme = "grpc", title = "gRPC", syntax = "grpc:service",
label = "rpc")
+@UriEndpoint(firstVersion = "2.19.0", scheme = "grpc", title = "gRPC", syntax = "grpc:host:port/service",
label = "rpc")
 public class GrpcEndpoint extends DefaultEndpoint {
     @UriParam
     protected final GrpcConfiguration configuration;
+    
+    private String serviceName;
+    private String servicePackage;
 
     public GrpcEndpoint(String uri, GrpcComponent component, GrpcConfiguration config) throws
Exception {
         super(uri, component);
         this.configuration = config;
+        
+        // Extract service and package names from the full service name
+        serviceName = GrpcUtils.extractServiceName(configuration.getService());
+        servicePackage = GrpcUtils.extractServicePackage(configuration.getService());
+        
+        // Convert method name to the camel case style
+        // This requires if method name as described inside .proto file directly
+        if (!ObjectHelper.isEmpty(configuration.getMethod())) {
+            configuration.setMethod(GrpcUtils.convertMethod2CamelCase(configuration.getMethod()));
+        }
     }
 
     public Producer createProducer() throws Exception {
@@ -53,4 +67,12 @@ public class GrpcEndpoint extends DefaultEndpoint {
     public boolean isSingleton() {
         return true;
     }
+    
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public String getServicePackage() {
+        return servicePackage;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcProducer.java
b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcProducer.java
index d05ad34..8cbfdfc 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcProducer.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcProducer.java
@@ -81,10 +81,10 @@ public class GrpcProducer extends DefaultProducer implements AsyncProcessor
{
             initializeChannel();
             if (endpoint.isSynchronous()) {
                 LOG.debug("Getting synchronous method stub from channel");
-                grpcStub = GrpcUtils.constructGrpcBlockingStub(configuration.getServicePackage(),
configuration.getServiceName(), channel, endpoint.getCamelContext());
+                grpcStub = GrpcUtils.constructGrpcBlockingStub(endpoint.getServicePackage(),
endpoint.getServiceName(), channel, endpoint.getCamelContext());
             } else {
                 LOG.debug("Getting asynchronous method stub from channel");
-                grpcStub = GrpcUtils.constructGrpcAsyncStub(configuration.getServicePackage(),
configuration.getServiceName(), channel, endpoint.getCamelContext());
+                grpcStub = GrpcUtils.constructGrpcAsyncStub(endpoint.getServicePackage(),
endpoint.getServiceName(), channel, endpoint.getCamelContext());
             }
             forwarder = GrpcExchangeForwarderFactory.createExchangeForwarder(configuration,
grpcStub);
 
@@ -112,13 +112,10 @@ public class GrpcProducer extends DefaultProducer implements AsyncProcessor
{
     protected void initializeChannel() {
         NettyChannelBuilder channelBuilder = null;
         if (!ObjectHelper.isEmpty(configuration.getHost()) && !ObjectHelper.isEmpty(configuration.getPort()))
{
-            LOG.info("Creating channel to the remote gRPC server " + configuration.getHost()
+ ":" + configuration.getPort());
+            LOG.info("Creating channel to the remote gRPC server {}:{}", configuration.getHost(),
configuration.getPort());
             channelBuilder = NettyChannelBuilder.forAddress(configuration.getHost(), configuration.getPort());
-        } else if (!ObjectHelper.isEmpty(configuration.getTarget())) {
-            LOG.info("Creating channel to the remote gRPC server " + configuration.getTarget());
-            channelBuilder = NettyChannelBuilder.forTarget(configuration.getTarget());
         } else {
-            throw new IllegalArgumentException("No connection properties (host, port or target)
specified");
+            throw new IllegalArgumentException("No connection properties (host or port) specified");
         }
         channel = channelBuilder.usePlaintext(configuration.getUsePlainText()).build();
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcUtils.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcUtils.java
b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcUtils.java
index 448c106..fe65a37 100644
--- a/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcUtils.java
+++ b/components/camel-grpc/src/main/java/org/apache/camel/component/grpc/GrpcUtils.java
@@ -35,6 +35,14 @@ public final class GrpcUtils {
 
     private GrpcUtils() {
     }
+    
+    public static String extractServiceName(String service) {
+        return service.contains(".") ? service.substring(service.lastIndexOf(".") + 1) :
service;
+    }
+
+    public static String extractServicePackage(String service) {
+        return service.contains(".") ? service.substring(0, service.lastIndexOf(".")) : "";
+    }
 
     public static Object constructGrpcAsyncStub(String packageName, String serviceName, Channel
channel, final CamelContext context) {
         return constructGrpcStubClass(packageName, serviceName, GrpcConstants.GRPC_SERVICE_ASYNC_STUB_METHOD,
channel, context);
@@ -56,7 +64,7 @@ public final class GrpcUtils {
         paramChannel[0] = Channel.class;
         Object grpcBlockingStub = null;
 
-        String serviceClassName = packageName + "." + serviceName + GrpcConstants.GRPC_SERVICE_CLASS_POSTFIX;
+        String serviceClassName = constructFullClassName(packageName, serviceName + GrpcConstants.GRPC_SERVICE_CLASS_POSTFIX);
         try {
             Class grpcServiceClass = context.getClassResolver().resolveMandatoryClass(serviceClassName);
             Method grpcBlockingMethod = ReflectionHelper.findMethod(grpcServiceClass, stubMethod,
paramChannel);
@@ -75,7 +83,7 @@ public final class GrpcUtils {
     public static Class constructGrpcImplBaseClass(String packageName, String serviceName,
final CamelContext context) {
         Class grpcServerImpl;
 
-        String serverBaseImpl = packageName + "." + serviceName + GrpcConstants.GRPC_SERVICE_CLASS_POSTFIX
+ "$" + serviceName + GrpcConstants.GRPC_SERVER_IMPL_POSTFIX;
+        String serverBaseImpl = constructFullClassName(packageName, serviceName + GrpcConstants.GRPC_SERVICE_CLASS_POSTFIX
+ "$" + serviceName + GrpcConstants.GRPC_SERVER_IMPL_POSTFIX);
         try {
             grpcServerImpl = context.getClassResolver().resolveMandatoryClass(serverBaseImpl);
 
@@ -165,4 +173,12 @@ public final class GrpcUtils {
         }
         return sb.toString();
     }
+    
+    private static String constructFullClassName(String packageName, String className) {
+        if (ObjectHelper.isEmpty(packageName)) {
+            return className;
+        } else {
+            return packageName + "." + className;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerAggregationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerAggregationTest.java
b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerAggregationTest.java
index be96c02..54506e1 100644
--- a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerAggregationTest.java
+++ b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerAggregationTest.java
@@ -166,10 +166,10 @@ public class GrpcConsumerAggregationTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("grpc://org.apache.camel.component.grpc.PingPong?synchronous=true&consumerStrategy=AGGREGATION&host=localhost&port="
+ GRPC_SYNC_REQUEST_TEST_PORT)
+                from("grpc://localhost:" + GRPC_SYNC_REQUEST_TEST_PORT + "/org.apache.camel.component.grpc.PingPong?synchronous=true&consumerStrategy=AGGREGATION")
                     .bean(new GrpcMessageBuilder(), "buildPongResponse");
                 
-                from("grpc://org.apache.camel.component.grpc.PingPong?synchronous=true&consumerStrategy=AGGREGATION&host=localhost&port="
+ GRPC_ASYNC_REQUEST_TEST_PORT)
+                from("grpc://localhost:" + GRPC_ASYNC_REQUEST_TEST_PORT + "/org.apache.camel.component.grpc.PingPong?synchronous=true&consumerStrategy=AGGREGATION")
                     .bean(new GrpcMessageBuilder(), "buildAsyncPongResponse");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerConcurrentTest.java
b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerConcurrentTest.java
index 8cddcc2..3bf1507 100644
--- a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerConcurrentTest.java
+++ b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerConcurrentTest.java
@@ -136,10 +136,10 @@ public class GrpcConsumerConcurrentTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("grpc://org.apache.camel.component.grpc.PingPong?synchronous=true&consumerStrategy=AGGREGATION&host=localhost&port="
+ GRPC_ASYNC_REQUEST_TEST_PORT)
+                from("grpc://localhost:" + GRPC_ASYNC_REQUEST_TEST_PORT + "/org.apache.camel.component.grpc.PingPong?synchronous=true&consumerStrategy=AGGREGATION")
                     .bean(new GrpcMessageBuilder(), "buildAsyncPongResponse");
                 
-                from("grpc://org.apache.camel.component.grpc.PingPong?synchronous=true&consumerStrategy=AGGREGATION&host=localhost&port="
+ GRPC_HEADERS_TEST_PORT)
+                from("grpc://localhost:" + GRPC_HEADERS_TEST_PORT + "/org.apache.camel.component.grpc.PingPong?synchronous=true&consumerStrategy=AGGREGATION")
                     .process(new HeaderExchangeProcessor());
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerPropagationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerPropagationTest.java
b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerPropagationTest.java
index 9d5fc5f..357e4dd 100644
--- a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerPropagationTest.java
+++ b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcConsumerPropagationTest.java
@@ -108,11 +108,11 @@ public class GrpcConsumerPropagationTest extends CamelTestSupport {
             @Override
             public void configure() {
                 
-                from("grpc://org.apache.camel.component.grpc.PingPong?consumerStrategy=PROPAGATION&host=localhost&port="
+ GRPC_ASYNC_NEXT_REQUEST_TEST_PORT)
+                from("grpc://localhost:" + GRPC_ASYNC_NEXT_REQUEST_TEST_PORT + "/org.apache.camel.component.grpc.PingPong?consumerStrategy=PROPAGATION")
                     .to("mock:async-on-next-propagation")
                     .bean(new GrpcMessageBuilder(), "buildAsyncPongResponse");
                 
-                from("grpc://org.apache.camel.component.grpc.PingPong?consumerStrategy=PROPAGATION&forwardOnCompleted=true&host=localhost&port="
+ GRPC_ASYNC_COMPLETED_REQUEST_TEST_PORT)
+                from("grpc://localhost:" + GRPC_ASYNC_COMPLETED_REQUEST_TEST_PORT + "/org.apache.camel.component.grpc.PingPong?consumerStrategy=PROPAGATION&forwardOnCompleted=true")
                     .to("mock:async-on-completed-propagation")
                     .bean(new GrpcMessageBuilder(), "buildAsyncPongResponse");
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerAsyncTest.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerAsyncTest.java
b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerAsyncTest.java
index fa7156d..b106059 100644
--- a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerAsyncTest.java
+++ b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerAsyncTest.java
@@ -52,7 +52,7 @@ public class GrpcProducerAsyncTest extends CamelTestSupport {
     @BeforeClass
     public static void startGrpcServer() throws Exception {
         grpcServer = ServerBuilder.forPort(GRPC_TEST_PORT).addService(new PingPongImpl()).build().start();
-        LOG.info("gRPC server started on port " + GRPC_TEST_PORT);
+        LOG.info("gRPC server started on port {}", GRPC_TEST_PORT);
     }
 
     @AfterClass
@@ -177,10 +177,10 @@ public class GrpcProducerAsyncTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("direct:grpc-sync-sync").to("grpc://org.apache.camel.component.grpc.PingPong?method=pingSyncSync&host=localhost&port="
+ GRPC_TEST_PORT);
-                from("direct:grpc-sync-async").to("grpc://org.apache.camel.component.grpc.PingPong?method=pingSyncAsync&host=localhost&port="
+ GRPC_TEST_PORT);
-                from("direct:grpc-async-sync").to("grpc://org.apache.camel.component.grpc.PingPong?method=pingAsyncSync&host=localhost&port="
+ GRPC_TEST_PORT);
-                from("direct:grpc-async-async").to("grpc://org.apache.camel.component.grpc.PingPong?method=pingAsyncAsync&host=localhost&port="
+ GRPC_TEST_PORT);
+                from("direct:grpc-sync-sync").to("grpc://localhost:" + GRPC_TEST_PORT + "/org.apache.camel.component.grpc.PingPong?method=pingSyncSync");
+                from("direct:grpc-sync-async").to("grpc://localhost:" + GRPC_TEST_PORT +
"/org.apache.camel.component.grpc.PingPong?method=pingSyncAsync");
+                from("direct:grpc-async-sync").to("grpc://localhost:" + GRPC_TEST_PORT +
"/org.apache.camel.component.grpc.PingPong?method=pingAsyncSync");
+                from("direct:grpc-async-async").to("grpc://localhost:" + GRPC_TEST_PORT +
"/org.apache.camel.component.grpc.PingPong?method=pingAsyncAsync");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerStreamingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerStreamingTest.java
b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerStreamingTest.java
index 3ed3848..1f1cc58 100644
--- a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerStreamingTest.java
+++ b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerStreamingTest.java
@@ -46,7 +46,7 @@ public class GrpcProducerStreamingTest extends CamelTestSupport {
     public void startGrpcServer() throws Exception {
         pingPongServer = new PingPongImpl();
         grpcServer = ServerBuilder.forPort(GRPC_TEST_PORT).addService(pingPongServer).build().start();
-        LOG.info("gRPC server started on port " + GRPC_TEST_PORT);
+        LOG.info("gRPC server started on port {}", GRPC_TEST_PORT);
     }
 
     @After
@@ -115,11 +115,10 @@ public class GrpcProducerStreamingTest extends CamelTestSupport {
             @Override
             public void configure() {
                 from("direct:grpc-stream-async-async-route")
-                        .to("grpc://org.apache.camel.component.grpc.PingPong?producerStrategy=STREAMING&streamRepliesTo=direct:grpc-replies&method=pingAsyncAsync&host=localhost&port="
-                                + GRPC_TEST_PORT);
+                    .to("grpc://localhost:" + GRPC_TEST_PORT + "/org.apache.camel.component.grpc.PingPong?producerStrategy=STREAMING&streamRepliesTo=direct:grpc-replies&method=pingAsyncAsync");
 
                 from("direct:grpc-replies")
-                        .to("mock:grpc-replies");
+                    .to("mock:grpc-replies");
             }
         };
     }
@@ -154,7 +153,7 @@ public class GrpcProducerStreamingTest extends CamelTestSupport {
                 @Override
                 public void onError(Throwable t) {
                     PingPongImpl.this.streamRequests.add(streamRequests);
-                    LOG.info("Error in pingAsyncAsync() " + t.getMessage());
+                    LOG.info("Error in pingAsyncAsync() {}", t.getMessage());
                 }
 
                 @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerSyncTest.java
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerSyncTest.java
b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerSyncTest.java
index 7bb9bf1..58f5415 100644
--- a/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerSyncTest.java
+++ b/components/camel-grpc/src/test/java/org/apache/camel/component/grpc/GrpcProducerSyncTest.java
@@ -54,7 +54,7 @@ public class GrpcProducerSyncTest extends CamelTestSupport {
     @BeforeClass
     public static void startGrpcServer() throws Exception {
         grpcServer = ServerBuilder.forPort(GRPC_TEST_PORT).addService(new PingPongImpl()).build().start();
-        LOG.info("gRPC server started on port " + GRPC_TEST_PORT);
+        LOG.info("gRPC server started on port {}", GRPC_TEST_PORT);
     }
 
     @AfterClass
@@ -76,13 +76,6 @@ public class GrpcProducerSyncTest extends CamelTestSupport {
         assertEquals(((PongResponse)pongResponse).getPongId(), GRPC_TEST_PING_ID);
         assertEquals(((PongResponse)pongResponse).getPongName(), GRPC_TEST_PING_VALUE + GRPC_TEST_PONG_VALUE);
 
-        // Testing simple sync method invoke with target instead of host and
-        // port parameters
-        pongResponse = template.requestBody("direct:grpc-sync-target", pingRequest);
-        assertNotNull(pongResponse);
-        assertTrue(pongResponse instanceof PongResponse);
-        assertEquals(((PongResponse)pongResponse).getPongId(), GRPC_TEST_PING_ID);
-
         // Testing simple sync method with name described in .proto file instead
         // of generated class
         pongResponse = template.requestBody("direct:grpc-sync-proto-method-name", pingRequest);
@@ -123,12 +116,10 @@ public class GrpcProducerSyncTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("direct:grpc-sync-sync").to("grpc://org.apache.camel.component.grpc.PingPong?method=pingSyncSync&host=localhost&port="
+ GRPC_TEST_PORT + "&synchronous=true");
-                from("direct:grpc-sync-target")
-                    .to("grpc://org.apache.camel.component.grpc.PingPong?method=pingSyncSync&target=dns:///localhost:"
+ GRPC_TEST_PORT + "&synchronous=true");
+                from("direct:grpc-sync-sync").to("grpc://localhost:" + GRPC_TEST_PORT + "/org.apache.camel.component.grpc.PingPong?method=pingSyncSync&synchronous=true");
                 from("direct:grpc-sync-proto-method-name")
-                    .to("grpc://org.apache.camel.component.grpc.PingPong?method=PingSyncSync&host=localhost&port="
+ GRPC_TEST_PORT + "&synchronous=true");
-                from("direct:grpc-sync-async").to("grpc://org.apache.camel.component.grpc.PingPong?method=pingSyncAsync&host=localhost&port="
+ GRPC_TEST_PORT + "&synchronous=true");
+                    .to("grpc://localhost:" + GRPC_TEST_PORT + "/org.apache.camel.component.grpc.PingPong?method=PingSyncSync&synchronous=true");
+                from("direct:grpc-sync-async").to("grpc://localhost:" + GRPC_TEST_PORT +
"/org.apache.camel.component.grpc.PingPong?method=pingSyncAsync&synchronous=true");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/d20dda74/components/camel-grpc/src/test/proto/pingpong.proto
----------------------------------------------------------------------
diff --git a/components/camel-grpc/src/test/proto/pingpong.proto b/components/camel-grpc/src/test/proto/pingpong.proto
index 4ee45b7..4dd0bc3 100644
--- a/components/camel-grpc/src/test/proto/pingpong.proto
+++ b/components/camel-grpc/src/test/proto/pingpong.proto
@@ -37,7 +37,7 @@ service PingPong {
   rpc PingAsyncAsync (stream PingRequest) returns (stream PongResponse) {}
 }
 
-// The request message containing the user's name.
+// The ping request message
 message PingRequest {
   string ping_name = 1;
   int32  ping_id   = 2;


Mime
View raw message