Search in sources :

Example 1 with REGISTRY_TYPE_KEY

use of org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY in project dubbo by alibaba.

the class NacosDubboServiceProviderBootstrap method main.

public static void main(String[] args) {
    ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-nacos-provider-demo");
    applicationConfig.setMetadataType(REMOTE_METADATA_STORAGE_TYPE);
    DubboBootstrap.getInstance().application(applicationConfig).registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?username=nacos&password=nacos").parameter(REGISTRY_TYPE_KEY, SERVICE_REGISTRY_TYPE)).protocol("dubbo", builder -> builder.port(20885).name("dubbo")).protocol("rest", builder -> builder.port(9090).name("rest")).service(builder -> builder.id("echo").interfaceClass(EchoService.class).ref(new EchoServiceImpl()).protocolIds("dubbo")).service(builder -> builder.id("user").interfaceClass(UserService.class).ref(new UserServiceImpl()).protocolIds("rest")).start().await();
}
Also used : REMOTE_METADATA_STORAGE_TYPE(org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE) UserServiceImpl(org.apache.dubbo.config.bootstrap.rest.UserServiceImpl) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) REGISTRY_TYPE_KEY(org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY) SERVICE_REGISTRY_TYPE(org.apache.dubbo.common.constants.RegistryConstants.SERVICE_REGISTRY_TYPE) UserService(org.apache.dubbo.config.bootstrap.rest.UserService) ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) UserService(org.apache.dubbo.config.bootstrap.rest.UserService) UserServiceImpl(org.apache.dubbo.config.bootstrap.rest.UserServiceImpl)

Example 2 with REGISTRY_TYPE_KEY

use of org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY in project dubbo by alibaba.

the class ZookeeperDubboServiceConsumerBootstrap method main.

public static void main(String[] args) throws Exception {
    DubboBootstrap bootstrap = DubboBootstrap.getInstance().application("zookeeper-dubbo-consumer", app -> app.metadata(COMPOSITE_METADATA_STORAGE_TYPE)).registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181").parameter(REGISTRY_TYPE_KEY, SERVICE_REGISTRY_TYPE).useAsConfigCenter(true).useAsMetadataCenter(true)).reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo").services("zookeeper-dubbo-provider")).reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest")).start();
    EchoService echoService = bootstrap.getCache().get(EchoService.class);
    UserService userService = bootstrap.getCache().get(UserService.class);
    for (int i = 0; i < 5; i++) {
        Thread.sleep(2000L);
        System.out.println(echoService.echo("Hello,World"));
        System.out.println(userService.getUser(i * 1L));
    }
    bootstrap.stop();
}
Also used : COMPOSITE_METADATA_STORAGE_TYPE(org.apache.dubbo.common.constants.CommonConstants.COMPOSITE_METADATA_STORAGE_TYPE) REGISTRY_TYPE_KEY(org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY) SERVICE_REGISTRY_TYPE(org.apache.dubbo.common.constants.RegistryConstants.SERVICE_REGISTRY_TYPE) UserService(org.apache.dubbo.config.bootstrap.rest.UserService) UserService(org.apache.dubbo.config.bootstrap.rest.UserService)

Aggregations

REGISTRY_TYPE_KEY (org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY)2 SERVICE_REGISTRY_TYPE (org.apache.dubbo.common.constants.RegistryConstants.SERVICE_REGISTRY_TYPE)2 UserService (org.apache.dubbo.config.bootstrap.rest.UserService)2 COMPOSITE_METADATA_STORAGE_TYPE (org.apache.dubbo.common.constants.CommonConstants.COMPOSITE_METADATA_STORAGE_TYPE)1 REMOTE_METADATA_STORAGE_TYPE (org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE)1 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)1 UserServiceImpl (org.apache.dubbo.config.bootstrap.rest.UserServiceImpl)1