Topic 16
■■■
Using Spring Remoting
An enterprise application typically needs to communicate with other applications. Take, for example, for
a company selling products; when a customer places an order, an order-processing system processes the
order and generates a transaction. During the order processing, an inquiry is made to the inventory
system to check whether the product is available in stock. Upon order confirmation, a notification is
sent to the fulfillment system to deliver the product to the customer. Finally, the information is sent to
the accounting system; an invoice is generated and the payment is processed.
Most of the time, this business process is not fulfilled by a single application but a number of
applications working together. Some of the applications may be developed in-house, and others may be
purchased from external vendors. Moreover, the applications may be running on different machines in
different locations and implemented with different technologies and programming languages (for
example, Java, .NET, C++, and so on). Performing the handshaking between applications in order to
build an efficient business process is always a critical task when architecting and implementing an
application. As a result, remoting support via various protocols and technologies is needed for an
application to participate well in an enterprise environment.
In the Java world, remoting support has existed since it was first created. In early days (Java 1.x),
most remoting requirements were implemented using traditional TCP sockets or Java Remote Method
Invocation (RMI). After J2EE came on the scene, EJB and JMS became common choices for
interapplication server communications. The rapid evolution of XML and the Internet gave rise to
remote support using XML over HTTP , including the Java API for XML-based RPC (JAX-RPC), the Java
API for XML Web Services (JAX-RPC), and HTTP-based technologies (for example, Hessian, Burlap, and
so on). Spring also offers its own HTTP-based remoting support, called the Spring HTTP invoker. In
recent years, to cope with the explosive growth of the Internet and more responsive web application
requirements (for example, via Ajax), more lightweight and efficient remoting support of applications
has become critical for the success of an enterprise. Consequently, the Java API for RESTful Web Services
(JAX-RS) was created and quickly gained popularity. Other protocols, such as Comet and HTML5
WebSocket, also attracted a lot of developers. Needless to say, remoting technologies keep evolving at a
rapid pace.
In terms of remoting, as mentioned, Spring provides its own support (for example, the Spring HTTP
invoker), as well as supports a lot of technologies mentioned earlier (for example, RMI, EJB, JMS,
Hessian, Burlap, JAX-RPC, JAX-WS, JAX-RS, and so on). It's not possible to cover all of them in this
chapter. So, here we will focus on those that are most commonly used. Specifically, this chapter will
cover the following topics:
Spring HTTP invoker: If both applications that need to communicate are Spring
·
based, the Spring HTTP invoker provides a simple and efficient way for invoking
the services exposed by other applications. We will show you how to use the
Spring HTTP invoker to expose a service within its service layer, as well as
invoking the services provided by a remote application.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home