In the previous article, we spoke about the architectural principles of SOA, and today we present our specific development examples. First of all, the development of the idea: 1. Putting all the interface functions under the same project, this project is very important, because our service providers and consumers will use; 2. For the specific implementation of the interface function, and to expose the corresponding services to the zookeeper registry; 3. Consumers only need to reference the interface function of the project; In the configuration file, The address in the registration and the generation of the remote service proxy can be called in the Java code. This is done for the consumer in fact the specific implementation details are not at this end but on the service provider side, if the service side of the code is updated (for example: the algorithm made a certain adjustment), then after the release, the consumer automatically call to the latest way. The specific engineering structure is as follows:
To parse the code focus:
Interface
The main is to define some basic functions of the interface Java files, provided for the consumer, service provider reference use; Relatively simple not to do more detailed description
Service Provider
Reference Interface Engineering (this place refers to the generation of the interface project, which means to put the production of the interfaces into this project), and implement this interface function; In this project, you also need to declare the Zookeeper registry address of the exposed service in the configuration file;
Consumers
Referencing the interface engineering, and obtaining the corresponding service address through the Zookeeper registry, making the call
The specific invocation situation is as follows:
This is just a simple implementation of the architecture process, we can flexibly apply to the actual project development process, so-called million change, this is an example. The project uses MAVEN engineering, everyone try ....
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Examples of SOA