Skip to Main Content
Java Message Service, 2nd Edition
book

Java Message Service, 2nd Edition

by Mark Richards, Richard Monson-Haefel, David A Chappell
May 2009
Intermediate to advanced content levelIntermediate to advanced
330 pages
10h 34m
English
O'Reilly Media, Inc.
Content preview from Java Message Service, 2nd Edition

The Spring JMS Namespace

Version 2.5 of the Spring Framework introduced the JMS XML namespace support, which greatly simplifies the configuration of message-driven POJOs. To add JMS namespace support to your configuration, you would simply specify the JMS schema in the <beans> element of your Spring application context XML file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jms="http://www.springframework.org/schema/jms"
       xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jms 
http://www.springframework.org/schema/jms/spring-jms-2.5.xsd">

Without the JMS namespace you must define a separate DefaultMessageListenerContainer bean for each message listener you define. In the following example, two message listeners are defined (messageListener1 and messageListener2), which listen on queue1 and queue2, respectively. Notice how you need to define two message listener containers, one for each message listener. This can get quite cumbersome and verbose when using multiple message listeners:

<bean id="messageListener1" class="org.springframework.jms.listener.adapter.MessageListenerAdapter"> <constructor-arg> <bean class="SimpleJMSReceiver1"/> </constructor-arg> <property name="defaultListenerMethod" value="processRequest"/> </bean> <bean id="messageListener2" class="org.springframework.jms.listener.adapter.MessageListenerAdapter"> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reactive Systems in Java

Reactive Systems in Java

Clement Escoffier, Ken Finnigan
Java 8 in Action

Java 8 in Action

Mario Fusco, Alan Mycroft, Raoul-Gabriel Urma
The Well-Grounded Java Developer, Second Edition

The Well-Grounded Java Developer, Second Edition

Benjamin Evans, Martijn Verburg, Jason Clark

Publisher Resources

ISBN: 9780596802264Supplemental ContentErrata Page