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

Connection Factories and JMS Destinations

The JmsTemplate class handles all of the logic for connecting to a JMS provider and accessing the JMS destinations. However, you still need to specify how the JmsTemplate class establishes the connection to the JMS provider. There are two ways to do this; using JNDI, or using the native connection factories and destination classes supplied by the provider. This section will go through the details of both of these methods, starting with JNDI.

Using JNDI

Spring provides several classes within its messaging framework for accessing JNDI-based connection factories and destinations. The advantage of this approach is that using JNDI further decouples your application from the JMS provider. The Spring classes needed when using JNDI to access the connection factories and JMS destinations are the JndiTemplate, JndiObjectFactoryBean, CachingConnectionFactory (or SingleConnectionFactory), JndiDestinationResolver, and finally the JmsTemplate. The relationship between these Spring classes and the JMS template is shown in Figure 9-4.

JNDI objects and the JmsTemplate

Figure 9-4. JNDI objects and the JmsTemplate

The first thing you need to do is define the JndiTemplate bean, which is used to specify the initial context factory, provider URL, and security credentials necessary to make a connection to the JMS provider. It is here that you would specify the TCP address and port for the JMS provider ...

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