Fundamentals and practices of distributed Java Applications reading notes three

Source: Internet
Author: User
Tags soap sca

For large distributed Java applications and SOA, we can analyze the following aspects:

    • Why SOA is needed
    • What SOA is
    • ebay's SOA platform
    • A way to implement SOA
Why SOA is needed

?? The first phenomenon is the problem of system diversification, which can be used to abstract the part of common logic to form a plurality of common business logic systems by domain; the second phenomenon is the typical problem of system traffic and data volume, which can be solved by means of split system. After building a common business logic system and splitting the system, the most obvious problem is how the system interacts. For the whole system's performance, usability and so on, the unified interactive mode becomes the obvious solution, the SOA is the first choice in this way.

What SOA is

?? SOA full name is Service Oriented architecture, it emphasizes that the system interacts with the standard service way, the system can adopt different language, different framework to implement, the interaction is all through the service way. Ebay has implemented an SOA platform to support the diversification of its business, and ebay believes that the greatest benefit of SOA is to improve the reusability and sensitivity of the business. However, the SOA platform also poses many challenges, such as:

    • Delay of service multi-level invocation: high-performance service interaction, perfect service call Process Control
    • Debugging/Tracking Difficulties:
    • Higher Safety/Inspection requirements: Each system after splitting must be monitored and controlled accordingly.
    • Existing application porting:
    • QoS Support: Limited access capacity per service provider, flow control, machine resource allocation, etc.
    • Highly available and highly scalable
    • Multi-version and dependency management
ebay's SOA platform

Based on these challenges, ebay has implemented an SOA platform that includes the following points:

    • High-performance, scalable, lightweight framework
    • Support for monitoring, safety control, flow control
    • Service Registration and Service warehouse
    • Development tools

For an SOA platform in a large application, you should include at least the following features:

    • Unified approach to service interaction and seamless integration with existing applications
    • Provides support for debugging/tracing
    • Dependency Management
    • High performance and high availability
An SOA-based approach to implementing an SOA platform from SCA

?? The full name of SCA is the service Component Architecture, which is the actual SOA implementation approach guidance. First, let's look at how the SCA standard defines the interaction of the service, including how to publish the service, how to invoke the service, and three aspects of the supported communication protocols and interactions.

Publishing services

?? Service follows SOA as an interface, and the publishing service first requires that the system itself has the corresponding interface implementation. In order to reduce the intrusion of the system implementation, through XML definition component mapping to the interface implementation of the system itself, after defining the component, the interface implemented by component can be published as a service. The XML sample file used to publish the service is as follows:

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://foo.com" name="HelloWorldComposite">    <component name="HelloWorldComponent">        <implementation.java class="DefaultHelloWorld"/>    </component>    <service name="HelloWorldService" promote="HelloWorldComponent">        <interface.java interface="HelloWorld"/>    </service></composite>

The main relationships of these tags are as follows:


Component tags are primarily defined by the implementation sub-label and integrated with existing systems, and SCA provides support for a wide range of implementation integrations. The service sub-label is used to indicate what the current component provides externally service,reference a sub-label to indicate what service the current component refers to.

Invoke Service

?? The way the service is invoked can also be achieved by simply defining XML. The XML sample code used to invoke the service is as follows:

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://foo.com" name="HelloWorldComposite">    <component name="HelloWorldComponent">        <implementation.spring location="beans.xml"/>        <reference name="HelloWorldService" target="HelloWorldService"/>    </component>    <reference name="HelloWorldService" promote="HelloWorldComponent">        <interface.java interface="HelloWorld"/>    </reference></composite>// Spring的beans.xml定义如下<beans>    <sca:reference name="HelloWorldService" type="HelloWorld"/></beans>
Supported communication and Interaction modes

?? The SCA standard provides the means of communication by default for SCA, WebService, and JMS three. SCA refers to the way that the framework chooses to use the appropriate means of communication based on the health state, for example, to switch local calls or WebService and JMS modes, depending on whether the server and client are on the same JVM. The implementation of WebService is HTTP, and JMS can be implemented in many ways, such as TCP/IP, HTTP, and so on.

?? SCA can publish and invoke services in a variety of ways without intruding into the system and inject them into new systems that need to reference the service, and these systems can also be implemented in many ways, such as Java, Spring, or C + +. From a standard perspective, SCA provides clear publishing services, call services, and support for seamless and existing application integration in a unified approach to service interaction. The SCA standard does not have a clear definition on debug/trace support, it can only be implemented on its own, there is no clear definition of dependency management, and the service warehouse is not defined, which brings greater difficulty to the implementation of dependency management.

Implementing an SOA platform based on an ESB

?? Unlike the ESB and SCA, which is not a standard of SOA implementation developed by multiple manufacturers, it can be considered that the ESB is only a concept, and the core idea is to realize the interaction between systems based on message middleware. The middle place of this system interaction based on the message middleware is called the bus, the data format of the interaction between the system adopts the unified message format, the conversion, routing, sending to the corresponding target application by the bus, and the system structure based on the ESB:

Typically the ESB framework must have 5 elements

    • Standard message Communication Format
    • Message routing: After the bus accepts the message, the system that needs to be called is determined based on the message data
    • Supports multiple types of message interactions: Request/Response and publish/subscribe, etc.
    • Supports multiple network protocols
    • Supports multiple data formats and can be converted to each other

?? In the unified service-mode interaction, it can be assumed that the message mode in the ESB interacts with this function, and supports a variety of communication and interaction (synchronous, asynchronous) mode, not defined on debug/trace support, and because all the interactions are carried out via the bus on the dependency management. Based on this, the dependence of each system can be judged and formed according to the flow of the message.

Implementing an SOA platform based on Tuscany

?? In the SCA implementation Framework, this book chooses Tuscany1.5 to analyze, which is one of the most commonly used SCA implementation frameworks, with an example of publishing services and invoking services based on the Tuny implementation. By providing an implementation of the HelloWorld interface, it is configured as a spring Bean and given to Tuscany to publish it as an SCA Service in webservice manner. The code is as follows:

HelloWorld Interface Definition @remotablepublic interface HelloWorld {public string SayHello (String name);} HelloWorld interface Implementation public class Defaulthelloworld implements HelloWorld {public string SayHello (String name) {RE    Turn "Server Response:hello" + name; The}}//Spring Bean XML is configured as follows <beans xmlns= "Http://www.springframework.org/schema/beans" xmlns:xsi= "http://www.w3.org /2001/xmlschema-instance "xmlns:sca=" Http://www.springframework.org/schema/sca "xsi:schemalocation="/HTTP/ Www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd/HTTP Www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd "> <sca:service name=" HelloWorldService "type=" HelloWorld "target=" Helloworldservicebean "/> <bean id=" Helloworldservicebean "class= "Defaulthelloworld" > </bean></beans>//Save the above file to the Resources/spring directory, named beans.xml// The configuration for publishing it as WebService based on Tuscany is as follows: <composite name= "HelloWorld" TargetnamespacE= "http://tuscany.apache.org/xmlns/sca/1.0" xmlns= "http://www.osoa.org/xmlns/sca/1.0" xmlns:nsl= "http// www.osoa.org/xmlns/sca/1.0 "> <service name=" helloworldservice "promote=" helloworldcomponent "> <inter    Face.java interface= "HelloWorld"/> <binding.ws uri= "Http://localhost:8080/services/HelloWorldService"/> </service> <component name= "helloworldcomponent" > <implementation.spring.location= "resoureces/sp Ring/beans.xml "/> </component></composite>//Save the above file to the SRC directory, named publishservice.composite// Write a startup class to complete the publication of the service public static void main (string[] args) throws Exception {scadomain.newinstance ("Publishservice.composi    TE ");    while (true) {thread.sleep (100000); }}

At this point, the Tuscany-based service publishing feature has been completed, and the code on how to invoke the service is not given.

?? After launching the code that publishes the SCA service, and then starting the code that invokes the SCA service, you can see the corresponding execution information on the console, and based on the above steps, it is easy to publish and invoke the SCA Servie in a webservice manner in spring. The following describes how the SOA platform is implemented based on Tuscany. First of all, from the interaction of the unified service, the Publishing Service, invoking the service and the supported network protocols and interactive mode are respectively seen.

    • Publishing services: Features in systems that support more implementations on the basis of the SCA Standard are published as SCA Service
    • Invoke Service: Supports more application integration and invocation methods, including more language support, on the basis of the SCA standard
    • Supported communication and Interaction modes: support for more communication methods based on the SCA standard

In the debug/trace aspect, when the server side throws an exception, this exception information will be brought back to the caller, which is helpful for error-checking, and Tuscany is not dedicated to management, high performance and high availability.

Implementing an SOA platform based on mule

?? Mule is one of the most commonly used ESB implementation frameworks, first to see how the same example functionality is implemented based on mule. In fact, Mule is also through the WebService way to provide HelloWorldService, and Tuscany in different places only in the configuration file and boot code two aspects, the configuration file removed Publishservice.composite, Instead, follow mule to write the following configuration file:

<mule>    <spring:beans>        <spring:import resource="resources/spring/mulepublisherbeans.xml"/>    </spring:beans>    <model name="HelloWorld">        <service name="HelloWorldService">            <inbound>                <axis:inbound-endpoint address="http://localhost:12345/services">                <soap:http-to-soap-request-transformer/>                </axis:inbound-endpoint>            </inbound>            <component>                <spring-object bean="HelloWorldBean"/>            <component>        </service>    </model></mule>// 将上面文件保存为publishservice.xml// 发布服务的启动代码遵循Mule改为如下方式MuleContext muleContext = new DefaultMuleContextFactory().createMuleContext("publishservice.xml");muleContext.start();

At this point, the Mule-based service publishing feature has been completed, and the code on how to invoke the service is not given.

?? Executing the above code enables the Mule service to invoke the remote Mule Service Release to WebService. We also take mule how to implement the SOA platform and see how mule implements the unified interaction of service modes.

    • Publish Service: Mule supports publishing spring or plain Java objects as Mule service in WebService, JMS, etc.
    • Invoke Service: Mule usage is more cumbersome because the ESB emphasizes that everything is sent to the bus in a message
    • Supported communication and Interaction modes: Support WebService and JMS two, support synchronous and asynchronous mode

Mule does not provide special support on Debug/trace, and in dependency management, Mule's Mulesoft provides an open source service governance framework: Mulegalaxy; Mule is not optimized for high performance and high availability.

Summary

?? The framework implemented by the SCA Standard and the SCA standard supports the unified interaction of services, and the ESB and ESB frameworks are better suited to scenarios where service interactions and complex multi-service interactions require decoupling, but whether based on SCA standards, ESBS, or existing SCA frameworks and ESB frameworks, There are a number of areas where you need to scale out the implementation of an SOA platform for a large application, especially in the areas of debug/trace, dependency management, high performance, and high availability. For the service of large-scale applications, the SOA platform is one aspect, how to promote the implementation is also an important factor, ebay refers to the existing application porting and training developers in the implementation of YA Xu carefully considered.

?? The characteristics of the SOA platform for a basic large-scale application mentioned above, and for a more complete SOA platform, the author believes that there are also the following points:

    • Support cluster environment: Software load Balancing, service interface or method level routing strategy, etc.
    • Perfect service governance: including dependency management, condition monitoring, security control, etc.
    • Services SOS (Quality of Service) support

Fundamentals and practices of distributed Java Applications reading notes three

Related Article

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.