Spring Book – Chapter 18 – Remoting

JMS

JMS stands for Java Messaging Services. The JMS remoting support in the Spring is provided by the org.springframework.jms.remoting.JmsInvokerServiceExporter and org.springframework.jms.remoting.JmsInvokerProxyFactoryBean classes.

JmsInvokerServiceExporter is JMS message listener that exports the specified service bean as a JMS service endpoint, accessible via a JMS invoker proxy.

JmsInvokerProxyFactoryBean is a FactoryBean for JMS invoker proxies. It exposes the proxied service for use as a bean reference, using the specified service interface. It serializes remote invocation objects and de-serializes remote invocation result objects and uses Java serialization just like RMI, but with the JMS provider as communication infrastructure. Listing 19-19 shows configuring spring configuration file for the JMS service exporter in the server side.

Listing 19-19. Configuring JMS service exporter in the server side

Listing 19-20 shows configuring client proxy for JMS in the client side in the Spring configuration file.

Listing 19-20. Configuring JMS client proxy in the client side

Does Spring Support EJB?

Spring does support EJB and provides the following two proxy factory beans to access the Enterprise Java Beans:

  • org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean – Used to access the EJB in the same container (local). It provides FactoryBean for local Stateless Session Bean (SLSB) proxies. It is designed for EJB 2.x, but works for EJB 3.x Session Beans as well. You can use org.springframework.jndi.JndiObjectLocator to specify the JNDI location of the target EJB.
  • org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean – Used to access remote EJB’s.

As explained earlier Spring remoting is achieved by Spring providing service exporters and client proxies. Spring does not provide any EJB Service Exporter and it provides four abstract support classes to make the development of Spring enabled EJB. They are:

  • org.springframework.ejb.support.AbstractMessageDrivenBean – Can be used to develop Message Driven Bean’s (MDB) that accept sources other than JMS. This class ensures that subclasses have access to the MessageDrivenContext provided by the EJB container.
  • org.springframework.ejb.support.AbstractJmsMessageDrivenBean – Can be used to develop MDB’s that accept messages from JMS sources.
  • org.springframework.ejb.support.AbstractStatelessSessionBean – Can be used to develop stateless session bean.
  • org.springframework.ejb.support.AbstractStstefulSessionBean – Can be used to develop stateful session bean.

Spring’s support of various remoting technologies can be pictorially represented as shown in Figure 19-7 below.

Figure 19-7. Spring Remoting support of various remoting technologies

Figure 19-7. Spring Remoting support of various remoting technologies

Page Visitors: 3772

The following two tabs change content below.
Tomcy John

Tomcy John

Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.
Tomcy John

Latest posts by Tomcy John (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *