The Spring AMQP project applies core Spring concepts to the development of AMQP-based messaging solutions. A “template” is provided as a high-level abstraction for sending and receiving messages, similar to other templates provided by the Spring framework. The interface that defines the main operations is called AmqpTemplate. This template is not unique to any implementation, hence the “AMQP” in the name. On the other hand, there are implementations of this interface that are tied to implementations of the AMQP protocol. The implementations of that protocol provide their own client libraries, so each implementation of the template interface will depend on a particular client library. Currently, there is only a single implementation: RabbitTemplate.
Spring AMQP is also capable of supporting Message-driven POJOs. These libraries facilitate management of AMQP resources while promoting the use of core principles based on which Spring framework is built on namely dependency injection and declarative configuration.
Spring Web Services
Spring Web Services is one of the projects from Spring community to develop the web services in easy manner. Spring Web Services follows the strategy, contract-first web services. It focuses more on XML and lesser on Java implementation.
Minute details of messaging using Spring will be explained in Chapter 14.
Contract-first web service
When developing web services, there are two approaches that we could take; contract-first and contract-last. When using the contract-last approach, you have to first write the Java code and let web service contract to be generated for that. When using the contract-first approach, you start with the web services contract and let Java implement the web service contract.
Complete discussion of Spring Web Services is out of scope of this book. I brought in this topic so that the reader knows that there such a topic in Spring framework which can be utilized if the need arises.
Spring WS-Quick Start
To create your web service based on Spring, do the following:
1. Create your XML schema (.xsd file). Inside the schema you will create your request messages and response messages. Bring up your favourite schema editor to create the schema or write sample request and response XML and then reverse-engineer the schema.
5. Now use Spring Web Service to point to the XSD and set up a few Spring managed beans and soon you have the web service ready. By doing it the Spring way no WSDL was written by the developer.
Spring Integration provides an extension of the Spring framework to support the well-known Enterprise Integration Patterns. It helps to extend the Spring programming into the messaging domain. Spring Integration’s primary goal is to provide a simple model for building enterprise integration solutions while maintaining the separation of concerns.
Spring Integration is very lightweight, and easily tested. Spring Integration works with standard technologies like EJB, RMI, and JMS, and enhances them by allowing you to model complex solutions in one place. Everything in your Spring integration configuration file is still a standard Spring application context, and benefits from the same dependency injection and aspect runtime available to regular Spring beans.
In this integration style each of two systems expose services that the other can call. An example of this is EJB services, or SOAP and REST services.
Some of the advantages of this integration style are:
- Usage is convenient
- Completely relates to the Object Oriented paradigm
- Speed of execution
Some of the disadvantages associated with this integration style are:
- Not interoperable
- Less scalable
- Lots of hidden complexities
Figure 6-5. Remoting Integration style
Spring’s POJO-based programming model is used for both your server and client, no matter which remoting solution is used in your application. This is accomplished using a proxy factory bean that enables you to wire remote services into properties of your other beans declared in your application as if they were local objects.
The client makes calls to the proxy as if this proxy is the one which actually provides the necessary service functionality which the client intended to call. This proxy actually doesn’t implement the service but communicates with the remote service on behalf of the client. The proxy handles the details of connecting and making remote calls to the remote service transparently.
Spring features integration classes for remoting support using various technologies. Currently, Spring supports the following remoting technologies:
- Remote Method Invocation (RMI)
- Spring’s own HttpInvoker
These will be explained to some extent in the following sections
Page Visitors: 2367