use of com.alibaba.dubbo.config.utils.ReferenceConfigCache in project tesla by linking12.
the class DynamicDubboClient method doRemoteCall.
@Override
public String doRemoteCall(final FilterRpcDO rpcDo, final String jsonInput) {
try {
final String serviceName = rpcDo.getServiceName();
final String methodName = rpcDo.getMethodName();
final String group = rpcDo.getServiceGroup();
final String version = rpcDo.getServiceVersion();
final String paramType = rpcDo.getInputParam();
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
reference.setApplication(applicationConfig);
reference.setRegistry(registryConfig);
reference.setInterface(serviceName);
reference.setGroup(group);
reference.setGeneric(true);
reference.setCheck(false);
reference.setVersion(version);
ReferenceConfigCache cache = ReferenceConfigCache.getCache();
GenericService genericService = cache.get(reference);
Pair<String[], Object[]> typeAndValue = paramTypeAndValue(paramType, jsonInput);
Object response = genericService.$invoke(methodName, typeAndValue.getLeft(), typeAndValue.getRight());
return JSON.toJSONString(response);
} catch (Throwable e) {
throw new IllegalArgumentException(String.format("service definition is wrong,please check the proto file you update,service is %s, method is %s", rpcDo.getServiceName(), rpcDo.getMethodName()), e);
}
}
Aggregations