commit | 6d1cfee2172d6b613741632cdd99326db697b188 | [log] [tgz] |
---|---|---|
author | Gong Dewei <kylixs@qq.com> | Fri Mar 19 14:40:32 2021 +0800 |
committer | GitHub <noreply@github.com> | Fri Mar 19 14:40:32 2021 +0800 |
tree | ef4d79501d844cc3fb56e2d61b353ac1ae0c437d | |
parent | 17c84efeee4289c69734b857548bcc1c9ede607b [diff] |
fix reference cache (#7412)
Apache Dubbo is a high-performance, Java based open source RPC framework. Please visit official site for quick start and documentations, as well as Wiki for news, FAQ, and release notes.
We are now collecting dubbo user info in order to help us to improve Dubbo better, pls. kindly help us by providing yours on issue#1012: Wanted: who's using dubbo, thanks :)
The following code snippet comes from Dubbo Samples. You may clone the sample project and step into dubbo-samples-api
sub directory before read on.
# git clone https://github.com/apache/dubbo-samples.git # cd dubbo-samples/java/dubbo-samples-api
There's a README file under dubbo-samples-api
directory. Read it and try this sample out by following the instructions.
<properties> <dubbo.version>2.7.8</dubbo.version> </properties> <dependencies> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo</artifactId> <version>${dubbo.version}</version> </dependency> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-dependencies-zookeeper</artifactId> <version>${dubbo.version}</version> <type>pom</type> </dependency> </dependencies>
package org.apache.dubbo.samples.api; public interface GreetingsService { String sayHi(String name); }
See api/GreetingsService.java on GitHub.
package org.apache.dubbo.samples.provider; import org.apache.dubbo.samples.api.GreetingsService; public class GreetingsServiceImpl implements GreetingsService { @Override public String sayHi(String name) { return "hi, " + name; } }
See provider/GreetingsServiceImpl.java on GitHub.
package org.apache.dubbo.samples.provider; import org.apache.dubbo.config.ApplicationConfig; import org.apache.dubbo.config.RegistryConfig; import org.apache.dubbo.config.ServiceConfig; import org.apache.dubbo.samples.api.GreetingsService; import java.util.concurrent.CountDownLatch; public class Application { private static String zookeeperHost = System.getProperty("zookeeper.address", "127.0.0.1"); public static void main(String[] args) throws Exception { ServiceConfig<GreetingsService> service = new ServiceConfig<>(); service.setApplication(new ApplicationConfig("first-dubbo-provider")); service.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181")); service.setInterface(GreetingsService.class); service.setRef(new GreetingsServiceImpl()); service.export(); System.out.println("dubbo service started"); new CountDownLatch(1).await(); } }
See provider/Application.java on GitHub.
# mvn clean package # mvn -Djava.net.preferIPv4Stack=true -Dexec.mainClass=org.apache.dubbo.samples.provider.Application exec:java
package org.apache.dubbo.samples.client; import org.apache.dubbo.config.ApplicationConfig; import org.apache.dubbo.config.ReferenceConfig; import org.apache.dubbo.config.RegistryConfig; import org.apache.dubbo.samples.api.GreetingsService; public class Application { private static String zookeeperHost = System.getProperty("zookeeper.address", "127.0.0.1"); public static void main(String[] args) { ReferenceConfig<GreetingsService> reference = new ReferenceConfig<>(); reference.setApplication(new ApplicationConfig("first-dubbo-consumer")); reference.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181")); reference.setInterface(GreetingsService.class); GreetingsService service = reference.get(); String message = service.sayHi("dubbo"); System.out.println(message); } }
See consumer/Application.java on GitHub.
# mvn clean package # mvn -Djava.net.preferIPv4Stack=true -Dexec.mainClass=org.apache.dubbo.samples.client.Application exec:java
The consumer will print out hi, dubbo
on the screen.
If you want to try out the cutting-edge features, you can build with the following commands. (Java 1.8 is required to build the master branch)
mvn clean install
Mailing list:
Bugs: Issues
Gitter: Gitter channel
Twitter: @ApacheDubbo
See CONTRIBUTING for details on submitting patches and the contribution workflow.
Good first issue
or Help wanted
.Please follow the template for reporting any issues.
Please report security vulnerability to us privately.
dubbo
to gather all Dubbo relevant projects not appropriate in apache group yetApache Dubbo is under the Apache 2.0 license. See the LICENSE file for details.