Distributed Service Framework HSF Learning

Source: Internet
Author: User
Tags serialization jboss

HSF provides a distributed service development framework, Taobao internal use, and generally provides the functions and some implementation basis:
1. Standard service-mode RPC
1), service definition: OSGi-based service definition mode
2), TCP/IP communication:
Io mode: NIO, using Mina framework
Connection mode: Long connection
Server-side connection pool with a limited size
WebService Way
3), serialization: Hessian serialization mechanism
2. Software load System
3. Modular, dynamic
4. Service governance

Here is a brief description of its use:
First, the HSF function is added to the project, is Maven, in Pom.xml to rely on Hsf:xml code <dependency> <groupid>com.taobao.hsf</groupid > <artifactId>hsf.connector.spring</artifactId> <version>xxx</version&    Gt </dependency>

For the service framework, there must be both service provider and consumer roles, and the work to be done by the provider includes:
1. Interface code into a jar package, put into the MAVEN repository for users to download and use, and the specific code implementation does not need to put into the jar package, the user can only invoke, can not see the implementation.
2. In the corresponding HSF configuration file, provide the services provided (spring-based Bean configuration): XML code    <bean id= "Xxxserviceimpl"  class= " Xxx.xxxserviceimpl " />   <bean id=" Xxxserviceprovider "      class= "Com.taobao.hsf.app.spring.util.HSFSpringProviderBean"  init-method= "Init" >         <property name= "Serviceinterface" >            <value>xxx.xxxService</value>         </property>        <property name= "Target" >           <ref bean= "Xxxserviceimpl"  />        </property>        <property  Name= "ServiceName" >           <value>xxxservice</ value>        </property>        <property name= " Serviceversion ">           <value>xxx</value>         </property>        < Property name= "Servicegroup" >           <value> hsf</value>        </property>   </bean>   

After the service has been successfully provided, the HSF service can be viewed in the HSF Service Management Center.
And the work to be done by the consumer: XML code <bean name= "Xxxservice" class= "Com.taobao.hsf.app.spring.util.HSFSpringConsumerBean" init-method= "Init" > <property name= "InterfaceName" value= "Xxx.xxxservice"/> <property name= "ver Sion "value=" xxx "/> </bean>

This service can then be used.

The drawback of HSF is that it uses the specified JBoss container, and also needs to include the SAR packet extension in the container such as JBoss, which is very intrusive to the user's operating environment, if you want to run on other containers such as WebLogic or WebSphere, You need to extend the container yourself to be compatible with HSF ClassLoader loading. Taobao have similar other frameworks Dubbo, introduction see
http://www.iteye.com/magazines/103

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.