use of com.alipay.sofa.rpc.test.EchoServiceImpl in project sofa-rpc by sofastack.
the class BoltServerMain method main.
public static void main(String[] args) {
ApplicationConfig application = new ApplicationConfig().setAppName("test-server");
ServerConfig serverConfig = new ServerConfig().setPort(22000).setDaemon(false);
ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>().setInterfaceId(HelloService.class.getName()).setApplication(application).setRef(new HelloServiceImpl()).setServer(serverConfig).setRegister(false);
ProviderConfig<EchoService> providerConfig2 = new ProviderConfig<EchoService>().setInterfaceId(EchoService.class.getName()).setApplication(application).setRef(new EchoServiceImpl()).setServer(serverConfig).setRegister(false);
providerConfig.export();
providerConfig2.export();
LOGGER.warn("started at pid {}", RpcRuntimeContext.PID);
}
use of com.alipay.sofa.rpc.test.EchoServiceImpl in project sofa-rpc by sofastack.
the class DubboServerMain method main.
public static void main(String[] args) {
ApplicationConfig applicationConfig = new ApplicationConfig().setAppName("dubbo-server");
ServerConfig serverConfig = new ServerConfig().setProtocol("dubbo").setHost("127.0.0.1").setPort(20080).setSerialization("hessian2").setDaemon(false);
ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>().setInterfaceId(HelloService.class.getName()).setBootstrap("dubbo").setApplication(applicationConfig).setRef(new HelloServiceImpl()).setUniqueId("xxx").setServer(serverConfig).setRegister(false);
ProviderConfig<EchoService> providerConfig2 = new ProviderConfig<EchoService>().setInterfaceId(EchoService.class.getName()).setRef(new EchoServiceImpl()).setApplication(applicationConfig).setBootstrap("dubbo").setUniqueId("xxx").setServer(serverConfig).setRegister(false);
providerConfig.export();
providerConfig2.export();
LOGGER.warn("started at pid {}", RpcRuntimeContext.PID);
synchronized (DubboServerMain.class) {
while (true) {
try {
DubboServerMain.class.wait();
} catch (InterruptedException e) {
}
}
}
}
use of com.alipay.sofa.rpc.test.EchoServiceImpl in project sofa-rpc by sofastack.
the class FutureServerMain method main.
public static void main(String[] args) {
ApplicationConfig applicationConfig = new ApplicationConfig().setAppName("future-server");
ServerConfig serverConfig2 = new ServerConfig().setPort(22222).setDaemon(false);
ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>().setApplication(applicationConfig).setInterfaceId(HelloService.class.getName()).setRef(new HelloServiceImpl(1000)).setServer(serverConfig2);
providerConfig.export();
ProviderConfig<EchoService> providerConfig2 = new ProviderConfig<EchoService>().setApplication(applicationConfig).setInterfaceId(EchoService.class.getName()).setRef(new EchoServiceImpl()).setServer(serverConfig2);
providerConfig2.export();
}
use of com.alipay.sofa.rpc.test.EchoServiceImpl in project sofa-rpc by sofastack.
the class OnewayServerMain method main.
public static void main(String[] args) {
ApplicationConfig applicationConfig = new ApplicationConfig().setAppName("oneway-server");
ServerConfig serverConfig2 = new ServerConfig().setPort(22222).setDaemon(false);
ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>().setApplication(applicationConfig).setInterfaceId(HelloService.class.getName()).setRef(new HelloServiceImpl(1000)).setServer(serverConfig2);
providerConfig.export();
ProviderConfig<EchoService> providerConfig2 = new ProviderConfig<EchoService>().setApplication(applicationConfig).setInterfaceId(EchoService.class.getName()).setRef(new EchoServiceImpl()).setServer(serverConfig2);
providerConfig2.export();
}
use of com.alipay.sofa.rpc.test.EchoServiceImpl in project sofa-rpc by sofastack.
the class ZookeeperAuthBoltServerTest method testUseCorrentAuth.
@Test
public void testUseCorrentAuth() {
parameters.put("scheme", "digest");
// 如果存在多个认证信息,则在参数形式为为user1:passwd1,user2:passwd2
parameters.put("addAuth", "sofazk:rpc1");
registryConfig = new RegistryConfig().setProtocol(RpcConstants.REGISTRY_PROTOCOL_ZK).setAddress("127.0.0.1:2181/authtest").setParameters(parameters);
serverConfig = new ServerConfig().setProtocol(// 设置一个协议,默认bolt
"bolt").setPort(// 设置一个端口,默认12200
12200).setDaemon(// 非守护线程
false);
ProviderConfig<EchoService> providerConfig = new ProviderConfig<EchoService>().setRegistry(registryConfig).setInterfaceId(// 指定接口
EchoService.class.getName()).setRef(// 指定实现
new EchoServiceImpl()).setServer(// 指定服务端
serverConfig);
// 发布服务
providerConfig.export();
ConsumerConfig<EchoService> consumerConfig = new ConsumerConfig<EchoService>().setRegistry(registryConfig).setInterfaceId(// 指定接口
EchoService.class.getName()).setProtocol(// 指定协议
"bolt").setTimeout(3000).setConnectTimeout(10 * 1000);
EchoService echoService = consumerConfig.refer();
String result = echoService.echoStr("auth test");
Assert.assertEquals("auth test", result);
}
Aggregations