I define a rpc service in a proto file, but I can not found any interface or method in the output java file.
$ protoc -v
libprotoc 2.5.0
proto file:
service EchoService {
rpc Echo (Person) returns (Person);
}
compile script:
#!/bin/bash
for file in `find src/main/proto -name "*.proto"`; do
protoc --proto_path=src/main/proto --java_out=src/main/java/ $file
done
You can use any text editor to create a . proto file. If you'd like to have syntax highlighting there are also editors that would give you that. I use IntelliJ but a quick Google search found an Eclipse plugin which appears to be free: https://code.google.com/p/protobuf-dt/.
Protocol buffers are a mechanism for sending data through the series of tubes known as the Internet. One common use of them is to define gRPC specifications — essentially a form of remote procedure calls. With gRPC service definitions, you create a “service” that has RPC methods.
Protocol buffers are a combination of the definition language (created in .proto files), the code that the proto compiler generates to interface with data, language-specific runtime libraries, and the serialization format for data that is written to a file (or sent across a network connection).
See the java_generic_services
option. You need to add this to your .proto
file:
option java_generic_services = true;
However, this is only useful if you have some RPC implementation to use with it (or want to write your own). The option defaults to false because it is expected that most RPC implementations will want to write a custom code generator rather than use the "generic" generated services.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With