Search in sources :

Example 6 with UserService

use of org.apache.dubbo.config.bootstrap.rest.UserService in project dubbo by alibaba.

the class ConsulDubboServiceConsumerBootstrap method main.

public static void main(String[] args) throws Exception {
    DubboBootstrap bootstrap = DubboBootstrap.getInstance().application("consul-dubbo-consumer", app -> app.metadata(DEFAULT_METADATA_STORAGE_TYPE)).registry("zookeeper", builder -> builder.address("consul://127.0.0.1:8500?registry-type=service&subscribed-services=consul-dubbo-provider").useAsConfigCenter(true).useAsMetadataCenter(true)).reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo")).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 : DEFAULT_METADATA_STORAGE_TYPE(org.apache.dubbo.common.constants.CommonConstants.DEFAULT_METADATA_STORAGE_TYPE) UserService(org.apache.dubbo.config.bootstrap.rest.UserService) UserService(org.apache.dubbo.config.bootstrap.rest.UserService)

Aggregations

UserService (org.apache.dubbo.config.bootstrap.rest.UserService)6 ApplicationConfig (org.apache.dubbo.config.ApplicationConfig)3 RegistryConfig (org.apache.dubbo.config.RegistryConfig)3 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)2 ServiceConfig (org.apache.dubbo.config.ServiceConfig)2 UserServiceImpl (org.apache.dubbo.config.bootstrap.rest.UserServiceImpl)2 Arrays (java.util.Arrays)1 COMPOSITE_METADATA_STORAGE_TYPE (org.apache.dubbo.common.constants.CommonConstants.COMPOSITE_METADATA_STORAGE_TYPE)1 DEFAULT_METADATA_STORAGE_TYPE (org.apache.dubbo.common.constants.CommonConstants.DEFAULT_METADATA_STORAGE_TYPE)1 REMOTE_METADATA_STORAGE_TYPE (org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE)1 REGISTRY_TYPE_KEY (org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY)1 SERVICE_REGISTRY_TYPE (org.apache.dubbo.common.constants.RegistryConstants.SERVICE_REGISTRY_TYPE)1 MetadataReportConfig (org.apache.dubbo.config.MetadataReportConfig)1 DubboBootstrap (org.apache.dubbo.config.bootstrap.DubboBootstrap)1 EchoService (org.apache.dubbo.config.bootstrap.EchoService)1