Skip to content

Commit

Permalink
[Issue apache#417] Address PR review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jinrongluo committed Dec 10, 2021
1 parent 56665af commit 0950b82
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
10 changes: 6 additions & 4 deletions eventmesh-sdk-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* limitations under the License.
*/

def grpcVersion = '1.15.0'

dependencies {
implementation project(":eventmesh-common")

Expand All @@ -26,10 +28,10 @@ dependencies {
implementation "io.netty:netty-all"
implementation "org.apache.httpcomponents:httpclient"

implementation "io.grpc:grpc-protobuf:1.15.0"
implementation "io.grpc:grpc-stub:1.15.0"
implementation "io.grpc:grpc-netty:1.15.0"
implementation "io.grpc:grpc-netty-shaded:1.15.0"
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
implementation "io.grpc:grpc-stub:${grpcVersion}"
implementation "io.grpc:grpc-netty:${grpcVersion}"
implementation "io.grpc:grpc-netty-shaded:${grpcVersion}"

testImplementation project(":eventmesh-common")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,31 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Publisher {
public class Producer {

private static Logger logger = LoggerFactory.getLogger(Publisher.class);
private static Logger logger = LoggerFactory.getLogger(Producer.class);

private ClientConfig clientConfig;

private ManagedChannel channel;

public Publisher(ClientConfig clientConfig) {
public Producer(ClientConfig clientConfig) {
this.clientConfig = clientConfig;
}

public void start() {
channel = ManagedChannelBuilder
.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort())
channel = ManagedChannelBuilder.forAddress(clientConfig.getServerAddr(), clientConfig.getServerPort())
.usePlaintext().build();
}

public void publish(String content) {
PublisherServiceGrpc.PublisherServiceBlockingStub publisherClient =
PublisherServiceGrpc.newBlockingStub(channel);
public boolean publish(String content) {
PublisherServiceGrpc.PublisherServiceBlockingStub publisherClient = PublisherServiceGrpc.newBlockingStub(channel);

Message message = Message.newBuilder().setContent(content).build();

Response response = publisherClient.publish(message);
logger.info("===========" + response.getRespCode() + " " + response.getRespMsg());
return true;
}

public void stop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public String toString() {
.append("pid=").append(pid).append(",")
.append("sys=").append(sys).append(",")
.append("userName=").append(userName).append(",")
.append("password=").append(password).append(",")
.append("password=").append("***").append(",")
.append("useTls=").append(useTls).append("}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void main(String[] args) throws Exception {
.setSys("1234")
.setPid(String.valueOf(ThreadUtil.getPID()));

Publisher publisher = new Publisher(clientConfig);
Producer publisher = new Producer(clientConfig);

publisher.start();
publisher.publish("hello world grpc!!");
Expand Down

0 comments on commit 0950b82

Please sign in to comment.