java grpc

java grpc maven依赖 <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-netty-shaded</artifactId> <version>1.31.0</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-protobuf</artifactId> <version>1.31.0</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-stub</artifactId> <version>1.31.0</version> </dependency> <dependency> <!-- necessary for Java 9+ --> <groupId>org.apache.tomcat</groupId> <artifactId>annotations-api</artifactId> <version>6.0.53</version> <scope>provided</scope> </dependency> create proto file in src/main/proto/foo.proto option java_package = “com.wiloon.foo”; maven 执行 mvn compile, 就可以在target/generated-sources 下看到生成的源码了 gradle build find generated source in build/generated/source/proto/main/grpc/com/wiloon/foo/foo.java https://grpc.io/docs/quickstart/java.html https://github.com/google/protobuf-gradle-plugin https://www.jianshu.com/p/59ac036b0d7b

2017-09-08 · 1 min · 55 words · -

grpc

python grpc grpcio==1.48.2 grpc 会忽略 linux 环境变量 里配置的 no_proxy, 导致请求失败, 在启动客户端之前 临时删除环境变量 unset HTTP_PROXY golang grpc gRPC 通过 HTTP2 协议传输 定义协议 protobuf syntax = "proto3"; message SearchRequest { string query = 1; int32 page_number = 2; int32 results_per_page = 3; } 生成 python 文件 python -m grpc_tools.protoc --python_out=. --grpc_python_out=. -I. logServer.proto python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. .\tests\remote\grpc_wrapper\service.proto golang grpc install protocol compiler plugins 在 https://pkg.go.dev/google.golang.org/protobuf/cmd/protoc-gen-go 可以看到最新的版本号 go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1.0 # 安装后查看 版本 ./protoc-gen-go --version ./protoc-gen-go-grpc --version protoc --go_out=. --go_opt=paths=source_relative \ --go-grpc_out=. --go-grpc_opt=paths=source_relative \ helloworld/helloworld.proto protoc -I proto/ proto/helloworld.proto -go_out=plugins=grpc:proto grpc-dump go install github.com/bradleyjkemp/grpc-tools/grpc-dump@latest grpc-dump --port=12345 http_proxy=http://localhost:12345 my-app wireshark grpc https://mp.weixin.qq.com/s/BdcFRO58ytrtcpYZVT1ymQ ...

2017-09-07 · 1 min · 133 words · -

RPC, Message Queue, MQ

RPC, Message Queue, MQ http://oldratlee.com/post/2013-02-01/synchronous-rpc-vs-asynchronous-message RPC 和 MQ 的区别 系统结构 RPC系统结构: Consumer 调用的 Provider 提供的服务。 +———-+—–+———-+ | Consumer | <=> | Provider | +—-+—–+—–+———-+ Message Queue 系统结构: Sender 发送消息给 Queue; Receiver 从 Queue 拿到消息来处理。 +——–+—–+——-+—–+———-+ | Sender | <=> | Queue | <=> | Receiver | +——–+—–+——-+—–+———-+ 功能特点 在架构上, RPC 和 Message 的差异点是, Message 有一个中间结点 Message Queue, 可以存储消息。 消息的特点 Message Queue 缓存请求压力, 然后逐渐释放出来, 消费者可以按照自己的节奏处理数据。 Message Queue 引入一个新的结点, 系统的可靠性会受 Message Queue 的影响。 Message Queue 是异步单向的消息。发送消息设计成是不需要等待消息处理的完成。 所以对于有同步返回需求, 用 Message Queue 则变得麻烦了。 ...

2015-02-06 · 1 min · 163 words · -