Search in sources :

Example 1 with EchoResponse

use of org.apache.skywalking.apm.testcase.baidu.brpc.interfaces.Echo.EchoResponse in project skywalking-java by apache.

the class CaseController method brpc.

@RequestMapping("/brpc")
@ResponseBody
public String brpc() {
    RpcClientOptions clientOption = new RpcClientOptions();
    clientOption.setProtocolType(Options.ProtocolType.PROTOCOL_BAIDU_STD_VALUE);
    clientOption.setWriteTimeoutMillis(1000);
    clientOption.setReadTimeoutMillis(5000);
    clientOption.setMaxTotalConnections(1000);
    clientOption.setMinIdleConnections(10);
    clientOption.setLoadBalanceType(LoadBalanceStrategy.LOAD_BALANCE_FAIR);
    clientOption.setCompressType(Options.CompressType.COMPRESS_TYPE_NONE);
    String serviceUrl = "list://127.0.0.1:1118";
    Echo.EchoRequest request = Echo.EchoRequest.newBuilder().setMessage("helloooooooooooo").build();
    RpcClient rpcClient = new RpcClient(serviceUrl, clientOption);
    EchoService echoService = BrpcProxy.getProxy(rpcClient, EchoService.class);
    try {
        EchoResponse response = echoService.echo(request);
    } catch (RpcException ex) {
    }
    rpcClient.stop();
    return SUCCESS;
}
Also used : EchoResponse(org.apache.skywalking.apm.testcase.baidu.brpc.interfaces.Echo.EchoResponse) RpcClientOptions(com.baidu.brpc.client.RpcClientOptions) Echo(org.apache.skywalking.apm.testcase.baidu.brpc.interfaces.Echo) EchoService(org.apache.skywalking.apm.testcase.baidu.brpc.interfaces.EchoService) RpcException(com.baidu.brpc.exceptions.RpcException) RpcClient(com.baidu.brpc.client.RpcClient) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

RpcClient (com.baidu.brpc.client.RpcClient)1 RpcClientOptions (com.baidu.brpc.client.RpcClientOptions)1 RpcException (com.baidu.brpc.exceptions.RpcException)1 Echo (org.apache.skywalking.apm.testcase.baidu.brpc.interfaces.Echo)1 EchoResponse (org.apache.skywalking.apm.testcase.baidu.brpc.interfaces.Echo.EchoResponse)1 EchoService (org.apache.skywalking.apm.testcase.baidu.brpc.interfaces.EchoService)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1