Java Code Examples for com.alibaba.dubbo.config.ServiceConfig#setTimeout()
The following examples show how to use
com.alibaba.dubbo.config.ServiceConfig#setTimeout() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DubboProviderBootstrap.java From sofa-rpc with Apache License 2.0 | 6 votes |
private void copyProvider(ProviderConfig<T> providerConfig, ServiceConfig<T> serviceConfig) { serviceConfig.setId(providerConfig.getId()); serviceConfig.setInterface(providerConfig.getInterfaceId()); serviceConfig.setRef(providerConfig.getRef()); serviceConfig.setGroup(providerConfig.getUniqueId()); serviceConfig.setVersion("1.0"); serviceConfig.setActives(providerConfig.getConcurrents()); serviceConfig.setDelay(providerConfig.getDelay()); serviceConfig.setDynamic(providerConfig.isDynamic()); serviceConfig.setRegister(providerConfig.isRegister()); serviceConfig.setProxy(providerConfig.getProxy()); serviceConfig.setWeight(providerConfig.getWeight()); if (providerConfig.getTimeout() > 0) { serviceConfig.setTimeout(providerConfig.getTimeout()); } serviceConfig.setParameters(providerConfig.getParameters()); }
Example 2
Source File: DubboServiceConfig.java From dubbo-mock with Apache License 2.0 | 6 votes |
public ServiceConfig<GenericService> fillDubboService(MockService mockService, com.tony.test.mock.po.RegistryConfig registryConfig, com.tony.test.mock.po.ProtocolConfig protocolConfig, MockGenericService tmpMockservice) { ServiceConfig<GenericService> service = new ServiceConfig<GenericService>(); service.setInterface(mockService.getServiceInterface()); service.setRef(tmpMockservice); // 指向一个通用服务实现 RegistryConfig registry = createRegistry(registryConfig.getRegistryAddress(), registryConfig.getRegistryTimeout()); service.setRegistry(registry); service.setProtocols(Lists.newArrayList(new ProtocolConfig(protocolConfig.getProtocolName(), protocolConfig.getProtocolPort()))); if (!StringUtils.isBlank(mockService.getGroupName())) { service.setGroup(mockService.getGroupName()); } service.setTimeout(mockService.getTimeout()); service.setRetries(mockService.getRetries()); service.setApplication(new ApplicationConfig(mockService.getApplicationName())); return service; }
Example 3
Source File: Application.java From skywalking with Apache License 2.0 | 5 votes |
@Bean(destroyMethod = "unexport") public ServiceConfig<GreetService> service() { ServiceConfig<GreetService> serviceConfig = new ServiceConfig<>(); serviceConfig.setApplication(applicationConfig); serviceConfig.setRegistry(registryConfig); serviceConfig.setProtocol(protocolConfig); serviceConfig.setInterface(GreetService.class); serviceConfig.setRef(new GreetServiceImpl()); serviceConfig.setTimeout(5000); serviceConfig.export(); return serviceConfig; }
Example 4
Source File: DubboEasyTransRpcProviderImpl.java From EasyTransaction with Apache License 2.0 | 4 votes |
@Override public void startService(Class<?> businessInterface,Map<BusinessIdentifer, RpcBusinessProvider<?>> businessList) { for(Entry<BusinessIdentifer, RpcBusinessProvider<?>> entry :businessList.entrySet()){ BusinessIdentifer key = entry.getKey(); final RpcBusinessProvider<?> value = entry.getValue(); GenericService genericService = new GenericService() { @Override public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { //第一个参数类型为easytransRequest,第二个为map(业务外 框架用的元数据) Method callMethod = getMethod(value.getClass(),method,new String[]{parameterTypes[0]}); try { Object invokeResult = callMethod.invoke(value, new Object[]{args[0]}); logger.debug("EasyTrans rpc call recived, executed success:" + args[0]); return invokeResult; } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { logger.info("EasyTrans rpc call recived,executed failed:" + args[0], e); throw new RuntimeException(e); } } }; ServiceConfig<GenericService> service = new ServiceConfig<GenericService>(); service.setInterface(businessInterface); service.setGroup(key.appId() + "-" + key.busCode()); service.setVersion("1.0.0"); service.setRef(genericService); service.setCluster("failfast"); int rpcTimeOut = key.rpcTimeOut(); if(rpcTimeOut != 0){ service.setTimeout(key.rpcTimeOut()); } service.setFilter("easyTransFilter"); if(applicationConfig != null) { service.setApplication(applicationConfig); } if(registryConfig != null) { service.setRegistry(registryConfig); } if(protocolConfig != null) { service.setProtocol(protocolConfig); } if(monitorConfig != null) { service.setMonitor(monitorConfig); } if(moduleConfig != null) { service.setModule(moduleConfig); } if(providerConfig != null) { service.setProvider(providerConfig); } if(customizationer != null) { customizationer.customDubboService(key,service); } service.export(); } }