Previous | Home | Next |
Spring provides various ways to develop remote services. Remote services are services hosted on remote servers and accessed by clients over the network. For example, lets say you are developing a desktop application that needs to connect to a central server. The desktop application can be on various machines. you can use spring remoting to connect the clients on the desktop to the server.
Web services developed using JAX-WS can also be developed and integrated using Spring. Currently, Spring supports the following remoting technologies:
- RMI- Remote Method Invocation - Use RMI to invoke a remote method. The java objects are serialized.
- Hessian- Transfer binary data between the client and the server.
- Burlap- Transfer XML data between the client and the server. It is the XML alternative to Hessian.
- JAX-WS- Java XML API for Web Services.
- Spring’s HTTP invoker- Spring provides a special remoting strategy which allows for Java serialization via HTTP, supporting any Java interface . The corresponding support classes are HttpInvokerProxyFactoryBean and HttpInvokerServiceExporter.
- JMS- Remoting using JMS as the underlying protocol is supported via the JmsInvokerServiceExporter and JmsInvokerProxyFactoryBean classes.
- AMQP- Remoting using AMQP as the underlying protocol is supported by the Spring AMQP project.
In this Topic we provide the Spring Remoting using RMI with workflow. Spring creates a proxy that represents the actual remote bean. The proxy is created using RmiProxyFactoryBean. The proxy can be used as a normal Spring bean and the client code does not need to know that it is actually calling a remote method.
The important classes org.springframework.aop.framework.ProxyFactory.RmiProxyFactoryBean. This class will be used by the client to create a proxy to connect to the remote service. This is a spring FactoryBean for creating RMI proxies. The proxied service is use a spring bean using the interface specified in the ServiceInterface property.
The Remote service URL can be specified by the serviceUrl property. org.springframework.remoting.rmi.RmiServiceExporter - This class will be used by the server to create a remote service. below diagram shows the process of RMI.

There are following steps to explain the diagram as follows:
- Client sends a message call.
- This message call is handled by an RMI Proxy created by RmiProxyFactoryBean.
- The RMI Proxy converts the call into a remote call over JRMP (Java Remote Method Protocol).
- The RMI Service Adapter created by RmiServiceExporter intercepts the remote call over JRMP.
- It forwards the method call to Service.
Previous | Home | Next |