Example of dubbo direct connection code and dubbo code

Source: Internet
Author: User

Example of dubbo direct connection code and dubbo code

We all know that dubbo is a distributed RPC tool. If we have time to allow it, we will write down dubbo. When we call or want to specify a machine for execution in the test environment, it does not require scheduling tools such as ZK. dubbo also provides the configuration solution. It is very simple to specify the URL, but this is not recorded here, it is called directly through code. This is recorded here. Let's talk about the code.

ApplicationConfig applicationConfig = new ApplicationConfig();        applicationConfig.setName("mix");        ReferenceConfig<TaskExecutor> referenceConfig = new ReferenceConfig<TaskExecutor>();        referenceConfig.setInterface("com.*.TaskExecutor");        referenceConfig.setUrl("dubbo://127.0.0.1:20880/com.*.TaskExecutor");        referenceConfig.setApplication(applicationConfig);        MethodConfig methodConfig = new MethodConfig();        methodConfig.setName("executeTask");        methodConfig.setAsync(false);        referenceConfig.setMethods(Arrays.asList(new MethodConfig[]{methodConfig}));        System.out.println(referenceConfig.get().executeTask(bean));    }

Com. *. taskExecutor is the full name of the interface, "dubbo: // 127.0.0.1: 20880/com. *. taskExecutor "is the service address," executeTask "is the method name, and bean is the method parameter.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.