0
votes

Running a gRPC based Java Client Server applications in Java. I was able to generate stubs for servers but when it comes intra-service communication, I'm unable to generate stubs for the client application that happens to be a war file running in wildfly. Here's the overview.

  1. Server -> Products (Jar running in a container)

  2. Client -> A War file running on Wildfly

Client is exposing a rest endpoint that in turns call Server.

My understanding is that I should share the proto file between 1 & 2. Following proto is copied both to 1 and 2 under src/main/proto

service ProductService {
    rpc findAll(google.protobuf.Empty) returns (Product);
}

message Product {
    string id = 1;
    string name = 2;
}

Question. Is my understand correct to share the protocol file between two isolated applications and then communicate between the two via generated stubs.

1

1 Answers

0
votes

Sharing the .proto is fine. You could also place the generated code into a library that is shared by client and server. You could also put the .proto into a shared location (like a repository) that both the client and server build processes use.

Copying the proto is easy and works. You just want to make sure you know what is the "canonical" version of the proto; you want to know what version should be updated first so that you know the most recent version of the proto. You don't want both the client maintainers and server maintainers to make changes to the proto and then need to figure out how to merge the changes.