Java-ice Getting Started Tutorial (2-1:ice Basics)

Source: Internet
Author: User

1. What is ice?
Ice is the Zeroc Open Source Communication protocol product, its full name is: The Internet Communications engine, translated into Chinese is the Internet communications engines, is an object-oriented middleware, so that we can build distributed applications at the lowest cost. Ice allows us to focus on the development of application logic, which handles all the underlying programming of the network interface, so we don't have to consider the details of opening the network connection, serialization and deserialization of the network data transfer, attempts to fail the connection, and so on.

2. Why is there ice?
Ice is a better solution for distributed applications, although there are some popular distributed application solutions, such as Microsoft's. NET (as well as the original DCOM), CORBA and Web service, but these object-oriented middleware has some shortcomings:
. NET is Microsoft products, only for the Windows system, and the actual situation is in the current network environment, different computers will run different systems, such as Linux above can not use. NET;
Although CORBA has done a lot of work on unified standards, there is still a lack of interoperability between different vendors, and no supplier can provide all the implementation support for all heterogeneous environments, and the implementation of CORBA is more complicated, and the cost of learning and implementation will be higher.
One of the most deadly drawbacks of Web service is his performance problem, which is rarely considered in a highly demanding industry.
The production of ice is due to the lack of middleware such as. NET, CORBA, and Web service, which can support different systems such as Windows, Linux, etc., and can be used in a variety of development languages, such as C + +, C, JAVA, RUBY, PYTHON, VB, etc. , the server can be any one of the above mentioned language implementation, the client can also be based on their actual situation to choose a different language implementation, such as the server using C language implementation, and the client in the Java language implementation, the underlying communication logic through the package of ice, we only need to focus on business logic.

3. How does ice work?
Ice is an object-oriented middleware platform, which means that ice provides tools, APIs, and library support for building object-oriented customer-server applications. To communicate with an object that is held by ice, the client must hold the proxy for the object (which is the same as the CORBA reference), where the proxy refers to an instance of the object, which the ice locates at run time, then looks for or activates it, and then passes the in parameter to the remote object. The return result is then obtained through the out parameter.
The agent mentioned here is also divided into direct agent and indirect agent, the direct agent has the identity of a certain object, and its server's running address, and the indirect proxy refers to the identity of an object stored inside it, and the object adapter name (adapter name). Indirect agents do not contain addressing information, in order to correctly locate the server, the client at run time will use the agent's internal object adapter name, pass it to a locator service, such as the Icepack service, then the locator will be the adapter name as a keyword, in the table containing the server address to find, The current server address is returned to the client, and the client run time now knows how to contact the server and will Dispatch (dispatch) the customer request as usual.
Ice can guarantee that in any network environment or operating system, the successful call only once, it will try to locate the remote server at run time, in the case of failure of the connection will make an attempt to repeat the connection, do not even the situation will give the user prompt.
When the client invokes the service-side method, it can be implemented synchronously or asynchronously, and the synchronous invocation is equivalent to calling its own local method, and the other behavior is blocked, and the asynchronous invocation is a very useful invocation, such as when the server needs to prepare the data from other asynchronous interfaces, this time the client does not need to wait, After the server data is ready to be fully charged, the client is notified by the message, and the server can do other things, and the client can get the data from the server.

4. Ice Call Mode
The network protocols that ICE employs are TCP, UDP, and SSL three, unlike Webservice,ice, which has several options in the invocation mode, and each of these schemes is choosing the characteristics of different network protocols.
Oneway (one-way invocation): The client simply registers the call to the local transmit buffer (the native Transport buffers) and returns immediately, without waiting for the return of the call result and not responsible for the result of the call.
Twoway (bidirectional invocation): The most common mode, synchronous method invocation mode, can only be used with TCP or SSL protocol.
Datagram (Datagram): Similar to the oneway call, the difference is that the Datagram call only takes the UDP protocol and can only invoke methods that have no return value and no output parameters.
Batchoneway (Bulk one-way invocation): The call is present in the call buffer, and a certain limit is reached to automatically send all requests (or manually erase buffers).
Batchdatagram (Bulk Datagram): similar to above.
The different invocation patterns actually correspond to the fixed business, for most of the methods that have return value or need real-time response, we may use the TwoWay method, for some businesses that do not need return value or do not depend on return value, we can use OneWay or Batchoneway way, For example, message notifications; the remaining datagram and Batchdatagram methods are typically used in businesses that have no return value and do not perform reliability checks, such as logs.

5. Structure of client and server

This illustration shows that using ice as a middleware platform, both client and server applications are composed of application code and ICE's library code mix.
Customer application and server application are the client and service side respectively.
The agent is implemented according to the ice file defined by slice, which provides a down-call interface that provides serialization and deserialization of the data.
The core part of ice, which provides core communication functions such as network connection between client and server, and the implementation of other network communication functions and possible problems, let us not pay attention to this piece when writing the application code, but focus on the implementation of the application function.


Java-ice Getting Started Tutorial (2-1:ice Basics)

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.