moehajj commented on issue #2205:
URL: https://github.com/apache/camel-k/issues/2205#issuecomment-817895840
Hi Team, I'm working alongside @viacheslav-fomin-main. I would like to
provide some context for this issue to help you reproduce if needed.
## The Proto File
Our `.proto` file looks something like this (we package it in
`com.sample.compute:compute-proto:1.0.0-SNAPSHOT`):
```
syntax = "proto3";
package com.sample.compute;
option java_package = "com.sample.compute";
option java_multiple_files = true;
message ComputeRequest {
Script script = 1;
Payload payload = 2;
map<string, string> context = 3;
map<string, string> system_context = 4;
}
message Payload {
bytes payload = 1;
}
message Script {
string type = 1;
string version = 2;
string script = 3;
}
message ComputeResponse {
Payload payload = 1;
map<string, string> context = 2;
map<string, string> system_context = 3;
}
service ComputeService {
rpc Compute(ComputeRequest) returns (ComputeResponse);
rpc ComputeStream(stream ComputeRequest) returns (stream ComputeResponse);
}
```
## The Java Route
Our `SampleGrpcCamelRoute.java` route looks like this:
```
package com.sample.compute.service.grpc;
import com.google.protobuf.ByteString;
import com.sample.compute.ComputeRequest;
import com.sample.compute.ComputeResponse;
import com.sample.compute.Payload;
import org.apache.camel.Message;
import org.apache.camel.builder.RouteBuilder;
import java.nio.charset.StandardCharsets;
public class SampleGrpcCamelRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
fromF("grpc://localhost:9000/com.sample.compute.ComputeService?synchronous=true")
.process(exchange -> {
final Message message = exchange.getMessage();
final ComputeRequest request =
message.getBody(ComputeRequest.class);
final String scriptOutputBody = "Hello World!";
final Payload responsePayload = Payload.newBuilder()
.setPayload(ByteString.copyFrom(scriptOutputBody.getBytes(StandardCharsets.UTF_8)))
.build();
final ComputeResponse response =
ComputeResponse.newBuilder()
.setPayload(responsePayload)
.build();
message.setBody(response);
});
}
}
```
We have verified this route works locally using java unit tests and Apache
Camel ContextTestSupport `org.apache.camel.ContextTestSupport`.
## Running using `kamel` CLI
We run the integration using the following command:
```
kamel run --dev \
-d mvn:com.sample.compute:compute-proto:1.0.0-SNAPSHOT \
-d mvn:org.apache.camel:camel-grpc:3.9.0 \
-d mvn:org.apache.camel:camel-componentdsl:3.9.0 \
SampleGrpcCamelRoute.java
```
Using `kubectl port-forward` on the integration pod we are able to verify
the grpc route is working using the same tests we had run locally.
We tried a plethora of camel-k `trait`s including:
```
--trait container.service-port=9000 \
--trait container.expose=true \
--trait knative.enabled=true \
--trait knative-service.enabled=true \
--trait
knative-service.autoscaling-class=kpa.autoscaling.knative.dev \
--trait knative-service.min-scale=1 \
--trait knative-service.max-scale=1 \
```
Thank you for the support!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]