Java Reference
In-Depth Information
To create a destination using the GlassFish Server, you create a JMS destination resource
that specifies a JNDI name for the destination.
In the GlassFish 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 destina-
tion resource.
In addition to injecting a connection factory resource into a client program, you usually
inject a destination resource. Unlike connection factories, destinations are specific to one
domain or the other. To create an application that allows you to use the same code for both
topics and queues, you assign the destination to a Destination object.
The following code specifies two resources, a queue and a topic. The resource names are
mapped to destination resources created in the JNDI namespace.
@Resource(lookup = "jms/Queue")
private static Queue queue;
@Resource(lookup = "jms/Topic")
private static Topic topic;
With the common interfaces, you can mix or match connection factories and destinations.
That is, in addition to using the ConnectionFactory interface, you can inject a
QueueConnectionFactory resource and use it with a Topic , and you can inject a
TopicConnectionFactory resource and use it with a Queue . The behavior of the
application will depend on the kind of destination you use and not on the kind of connec-
tion factory you use.
JMS Connections
A connection encapsulates a virtual connection with a JMS provider. For example, a con-
nection could represent an open TCP/IP socket between a client and a provider service
daemon. You use a connection to create one or more sessions.
Note
In the Java EE platform, the ability to create multiple sessions from a
single connection is limited to application clients. In web and enterprise
bean components, a connection can create no more than one session.
Connections implement the Connection interface. When you have a Connec-
tionFactory object, you can use it to create a Connection :
Search WWH ::




Custom Search