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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
<bean id="requestQueue"> <!-- Cofigure JMS queue --> </bean> <bean id="connectionFactory"> <!-- Configure JMS connection factory --> </bean> <bean id="loyaltyService"/> <bean id="listener"> <property name="service" ref="loyaltyService"/> <property name="serviceInterface" value="com.mybook.loyalty.services.LoyaltyService"/> </bean> <bean id="container" class="org.springframework.jms.listener.SimpleMessageListenerContainer"> <property name="connectionFactory" ref="connectionFactory"/> <property name="messageListener" ref="listener"/> <property name="destination" ref="requestQueue"/> </bean> |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<bean id="requestQueue"> <!-- Cofigure JMS queue --> </bean> <bean id="connectionFactory"> <!-- Configure JMS connection factory --> </bean> <bean id="loyaltyService" class="org.springframework.jms.remoting.JmsInvokerProxyFactoryBean"> <property name="connectionFactory" ref="connectionFactory"/> <property name="queue" ref="requestQueue"/> <property name="serviceInterface" value="com.mybook.loyalty.services.LoyaltyService"/> </bean> |
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
Page Visitors: 4713

Tomcy John

Latest posts by Tomcy John (see all)
- A Guide to Continuous Improvement for Architects - February 2, 2023
- Cloud-first Architecture Strategy - January 26, 2023
- Architecture Strategy and how to create One - January 24, 2023