本文整理汇总了Java中com.alibaba.dubbo.config.ReferenceConfig.setTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java ReferenceConfig.setTimeout方法的具体用法?Java ReferenceConfig.setTimeout怎么用?Java ReferenceConfig.setTimeout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.config.ReferenceConfig
的用法示例。
在下文中一共展示了ReferenceConfig.setTimeout方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createClient
import com.alibaba.dubbo.config.ReferenceConfig; //导入方法依赖的package包/类
protected T createClient(Class<T> cls, String targetIP, int targetPort, int connectTimeout,int clientNums){
ReferenceConfig<T> referenceConfig = new ReferenceConfig<T>();
referenceConfig.setInterface(cls);
StringBuilder url = new StringBuilder();
url.append("dubbo://");
url.append(targetIP);
url.append(":");
url.append(targetPort);
url.append("/");
url.append(cls.getName());
referenceConfig.setUrl(url.toString());
// hardcode
referenceConfig.setConnections(clientNums);
ApplicationConfig application = new ApplicationConfig();
application.setName("dubbo_consumer");
referenceConfig.setApplication(application);
referenceConfig.setTimeout(connectTimeout);
return referenceConfig.get();
}
示例2: createClient
import com.alibaba.dubbo.config.ReferenceConfig; //导入方法依赖的package包/类
protected T createClient(Class<T> cls, String targetIP, int targetPort, int connectTimeout,int clientNums, String protocol, String serialization){
ReferenceConfig<T> referenceConfig = new ReferenceConfig<T>();
referenceConfig.setInterface(cls);
StringBuilder url = new StringBuilder();
url.append(protocol);
url.append("://");
url.append(targetIP);
url.append(":");
url.append(targetPort);
url.append("/");
url.append(cls.getName());
url.append("?optimizer=com.alibaba.dubbo.rpc.benchmark.SerializationOptimizerImpl");
if (!StringUtils.isEmpty(serialization)) {
url.append("&serialization=");
url.append(serialization);
}
referenceConfig.setUrl(url.toString());
// hardcode
referenceConfig.setConnections(clientNums);
ApplicationConfig application = new ApplicationConfig();
application.setName("dubbo_consumer");
referenceConfig.setApplication(application);
referenceConfig.setTimeout(connectTimeout);
return referenceConfig.get();
}
示例3: getService
import com.alibaba.dubbo.config.ReferenceConfig; //导入方法依赖的package包/类
public static <S> S getService(Class<S> c){
ApplicationConfig application = new ApplicationConfig();
application.setName("beast-litx");
RegistryConfig registry = new RegistryConfig();
registry.setAddress("zookeeper://114.55.174.189:2181");
registry.setGroup("dubbo-zhang");
ReferenceConfig<S> reference = new ReferenceConfig<S>();
reference.setApplication(application);
reference.setRegistry(registry);
reference.setInterface(c);
reference.setTimeout(30000);
reference.setRetries(0);
S service = reference.get();
return service;
}
示例4: createClient
import com.alibaba.dubbo.config.ReferenceConfig; //导入方法依赖的package包/类
/**
* 创建连接到该service上的reference bean的客户端配置实例,好吧,实际上核心就是一个url地址
*
* @param cls
* @param targetIP
* @param targetPort
* @param connectTimeout
* @param clientNums
* @return
*/
protected T createClient(Class<T> cls, String targetIP, int targetPort, int connectTimeout,int clientNums){
ReferenceConfig<T> referenceConfig = new ReferenceConfig<T>();
referenceConfig.setInterface(cls);
StringBuilder url = new StringBuilder();
url.append("dubbo://");
url.append(targetIP);
url.append(":");
url.append(targetPort);
url.append("/");
url.append(cls.getName());
referenceConfig.setUrl(url.toString());
// hardcode
referenceConfig.setConnections(clientNums);
ApplicationConfig application = new ApplicationConfig(); // 在这个里面有注册中心列表
application.setName("dubbo_consumer");
referenceConfig.setApplication(application);
referenceConfig.setTimeout(connectTimeout);
return referenceConfig.get();
}
示例5: createClient
import com.alibaba.dubbo.config.ReferenceConfig; //导入方法依赖的package包/类
protected T createClient(Class<T> cls, String targetIP, int targetPort, int connectTimeout, int clientNums) {
ReferenceConfig<T> referenceConfig = new ReferenceConfig<T>();
referenceConfig.setInterface(cls);
StringBuilder url = new StringBuilder();
url.append("dubbo://");
url.append(targetIP);
url.append(":");
url.append(targetPort);
url.append("/");
url.append(cls.getName());
referenceConfig.setUrl(url.toString());
// hardcode
referenceConfig.setConnections(clientNums);
ApplicationConfig application = new ApplicationConfig();
application.setName("dubbo_consumer");
referenceConfig.setApplication(application);
referenceConfig.setTimeout(connectTimeout);
return referenceConfig.get();
}
示例6: getRemoteService
import com.alibaba.dubbo.config.ReferenceConfig; //导入方法依赖的package包/类
/**
* 从远程注册中心获取服务
*
* @param clazz 接口Class对象
* @param version 服务版本
* @param <T> T
* @return 对应服务
*/
private <T> T getRemoteService(Class<T> clazz, String... version) {
// 引用远程服务
ReferenceConfig<T> reference = new ReferenceConfig<>();
reference.setApplication(application);
reference.setRegistry(registry);
if (version != null && version.length != 0) {
reference.setVersion(version[0]);
}
reference.setTimeout(10000);
reference.setInterface(clazz);
return reference.get();
}
示例7: getServiceByUrl
import com.alibaba.dubbo.config.ReferenceConfig; //导入方法依赖的package包/类
/**
* 获取点对点直连的service
* @param clazz 接口Class对象
* @param url URL地址
* @param version 服务版本
* @param <T> T
* @return 对象
*/
private <T> T getServiceByUrl(Class<T> clazz, String url, String... version) {
ReferenceConfig<T> reference = new ReferenceConfig<T>();
reference.setApplication(application);
reference.setUrl(url);
reference.setInterface(clazz);
reference.setTimeout(10000);
if (version != null && version.length != 0) {
reference.setVersion(version[0]);
}
return reference.get();
}
示例8: connectRegistry
import com.alibaba.dubbo.config.ReferenceConfig; //导入方法依赖的package包/类
public void connectRegistry() {
Long s = System.currentTimeMillis();
ReferenceConfig<RegistryService> reference = new ReferenceConfig<RegistryService>();
reference.setApplication(application);
reference.setRegistries(registryList); // 多个注册中心可以用setRegistries()
reference.setInterface(RegistryService.class); // 弱类型接口名
reference.setRetries(0);
reference.setTimeout(5000);
RegistryService registryService = reference.get();
Long t = System.currentTimeMillis() - s;
logger.info("connectRegistry success ,spend time=" + t + "ms");
}