Search in sources :

Example 1 with EchoServiceImpl

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);
}
Also used : ServerConfig(com.alipay.sofa.rpc.config.ServerConfig) ApplicationConfig(com.alipay.sofa.rpc.config.ApplicationConfig) EchoService(com.alipay.sofa.rpc.test.EchoService) HelloService(com.alipay.sofa.rpc.test.HelloService) HelloServiceImpl(com.alipay.sofa.rpc.test.HelloServiceImpl) EchoServiceImpl(com.alipay.sofa.rpc.test.EchoServiceImpl)

Example 2 with EchoServiceImpl

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) {
            }
        }
    }
}
Also used : ServerConfig(com.alipay.sofa.rpc.config.ServerConfig) ApplicationConfig(com.alipay.sofa.rpc.config.ApplicationConfig) EchoService(com.alipay.sofa.rpc.test.EchoService) HelloService(com.alipay.sofa.rpc.test.HelloService) HelloServiceImpl(com.alipay.sofa.rpc.test.HelloServiceImpl) EchoServiceImpl(com.alipay.sofa.rpc.test.EchoServiceImpl)

Example 3 with EchoServiceImpl

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();
}
Also used : ServerConfig(com.alipay.sofa.rpc.config.ServerConfig) ApplicationConfig(com.alipay.sofa.rpc.config.ApplicationConfig) ProviderConfig(com.alipay.sofa.rpc.config.ProviderConfig) EchoService(com.alipay.sofa.rpc.test.EchoService) HelloService(com.alipay.sofa.rpc.test.HelloService) HelloServiceImpl(com.alipay.sofa.rpc.test.HelloServiceImpl) EchoServiceImpl(com.alipay.sofa.rpc.test.EchoServiceImpl)

Example 4 with EchoServiceImpl

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();
}
Also used : ServerConfig(com.alipay.sofa.rpc.config.ServerConfig) ApplicationConfig(com.alipay.sofa.rpc.config.ApplicationConfig) ProviderConfig(com.alipay.sofa.rpc.config.ProviderConfig) EchoService(com.alipay.sofa.rpc.test.EchoService) HelloService(com.alipay.sofa.rpc.test.HelloService) HelloServiceImpl(com.alipay.sofa.rpc.test.HelloServiceImpl) EchoServiceImpl(com.alipay.sofa.rpc.test.EchoServiceImpl)

Example 5 with EchoServiceImpl

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);
}
Also used : RegistryConfig(com.alipay.sofa.rpc.config.RegistryConfig) ServerConfig(com.alipay.sofa.rpc.config.ServerConfig) EchoService(com.alipay.sofa.rpc.test.EchoService) ProviderConfig(com.alipay.sofa.rpc.config.ProviderConfig) EchoServiceImpl(com.alipay.sofa.rpc.test.EchoServiceImpl) Test(org.junit.Test) BaseZkTest(com.alipay.sofa.rpc.registry.base.BaseZkTest)

Aggregations

ServerConfig (com.alipay.sofa.rpc.config.ServerConfig)10 EchoService (com.alipay.sofa.rpc.test.EchoService)10 EchoServiceImpl (com.alipay.sofa.rpc.test.EchoServiceImpl)10 HelloService (com.alipay.sofa.rpc.test.HelloService)9 HelloServiceImpl (com.alipay.sofa.rpc.test.HelloServiceImpl)9 ProviderConfig (com.alipay.sofa.rpc.config.ProviderConfig)8 ApplicationConfig (com.alipay.sofa.rpc.config.ApplicationConfig)5 RegistryConfig (com.alipay.sofa.rpc.config.RegistryConfig)4 SwaggerRestService (com.alipay.sofa.rpc.doc.swagger.rest.SwaggerRestService)1 SwaggerRestServiceImpl (com.alipay.sofa.rpc.doc.swagger.rest.SwaggerRestServiceImpl)1 BaseZkTest (com.alipay.sofa.rpc.registry.base.BaseZkTest)1 Test (org.junit.Test)1