background image

JMS Connection Factories

<< JMS Administered Objects | JMS Connections >>
<< JMS Administered Objects | JMS Connections >>

JMS Connection Factories

JMS clients access these objects through interfaces that are portable, so a client application can
run with little or no change on more than one implementation of the JMS API. Ordinarily, an
administrator configures administered objects in a JNDI namespace, and JMS clients then
access them by using resource injection.
With Sun Java System Application Server Platform Edition 9, you use the asadmin command or
the Admin Console to create JMS administered objects in the form of resources.
JMS Connection Factories
A connection factory is the object a client uses to create a connection to a provider. A connection
factory encapsulates a set of connection configuration parameters that has been defined by an
administrator. Each connection factory is an instance of the ConnectionFactory,
QueueConnectionFactory
, or TopicConnectionFactory interface. To learn how to create
connection factories, see
"Creating JMS Administered Objects for the Synchronous Receive
Example" on page 915
.
At the beginning of a JMS client program, you usually inject a connection factory resource into
a ConnectionFactory object. For example, the following code fragment specifies a resource
whose JNDI name is jms/ConnectionFactory and assigns it to a ConnectionFactory object:
@Resource(mappedName=
"jms/ConnectionFactory")
private static ConnectionFactory connectionFactory;
In a Java EE application, JMS administered objects are normally placed in the jms naming
subcontext.
Note ­
The mappedName element of the @Resource annotation is specific to the Application
Server.
JMS Destinations
A destination is the object a client uses to specify the target of messages it produces and the
source of messages it consumes. In the PTP messaging domain, destinations are called queues.
In the pub/sub messaging domain, destinations are called topics. A JMS application can use
multiple queues or topics (or both). To learn how to create destination resources, see
"Creating
JMS Administered Objects for the Synchronous Receive Example" on page 915
.
To create a destination using the Application Server, you create a JMS destination resource that
specifies a JNDI name for the destination.
In the Application Server implementation of JMS, each destination resource refers to a physical
destination. You can create a physical destination explicitly, but if you do not, the Application
Server creates it when it is needed and deletes it when you delete the destination resource.
The JMS API Programming Model
The Java EE 5 Tutorial · September 2007
902