use of com.alipay.sofa.rpc.event.ClientBeforeSendEvent in project sofa-rpc by sofastack.
the class AbstractHttp2ClientTransport method beforeSend.
/**
* 调用前设置一些属性
*
* @param context RPC上下文
* @param request 请求对象
*/
protected void beforeSend(RpcInternalContext context, SofaRequest request) {
currentRequests.incrementAndGet();
context.getStopWatch().tick().read();
context.setLocalAddress(localAddress());
if (EventBus.isEnable(ClientBeforeSendEvent.class)) {
EventBus.post(new ClientBeforeSendEvent(request));
}
}
use of com.alipay.sofa.rpc.event.ClientBeforeSendEvent in project sofa-rpc by sofastack.
the class AbstractProxyClientTransport method syncSend.
@Override
public SofaResponse syncSend(SofaRequest request, int timeout) throws SofaRpcException {
RpcInternalContext context = RpcInternalContext.getContext();
SofaResponse response = null;
SofaRpcException throwable = null;
try {
beforeSend(context, request);
if (EventBus.isEnable(ClientBeforeSendEvent.class)) {
EventBus.post(new ClientBeforeSendEvent(request));
}
response = doInvokeSync(request, timeout);
return response;
} catch (InvocationTargetException e) {
throwable = convertToRpcException(e);
throw throwable;
} catch (SofaRpcException e) {
throwable = e;
throw e;
} catch (Exception e) {
throwable = new SofaRpcException(RpcErrorType.CLIENT_UNDECLARED_ERROR, "Failed to send message to remote", e);
throw throwable;
} finally {
afterSend(context, request);
if (EventBus.isEnable(ClientSyncReceiveEvent.class)) {
EventBus.post(new ClientSyncReceiveEvent(transportConfig.getConsumerConfig(), transportConfig.getProviderInfo(), request, response, throwable));
}
}
}
use of com.alipay.sofa.rpc.event.ClientBeforeSendEvent in project sofa-rpc by sofastack.
the class BoltClientTransport method beforeSend.
/**
* 调用前设置一些属性
*
* @param context RPC上下文
* @param request 请求对象
*/
protected void beforeSend(RpcInternalContext context, SofaRequest request) {
currentRequests.incrementAndGet();
context.setLocalAddress(localAddress());
if (EventBus.isEnable(ClientBeforeSendEvent.class)) {
EventBus.post(new ClientBeforeSendEvent(request));
}
}
Aggregations