The JMS API allows loosely coupled, reliable, asynchronous interactions among Java EE components
and legacy systems capable of messaging. You can add new behavior
to a Java EE application that has existing business events by adding a new message-driven
bean to operate on specific business events. Java EE components that use the JMS API within EJB
or web containers must have no more than one JMS session per JMS connection. For more, see
About Message-Driven Beans.
The JMS API uses two kinds of administered resource objects:
Connection Factories (Connector Resource). These objects are used to create a connection to the JMS messaging system,
and encapsulate connection parameters.
Destination Resources (Admin Object Resource). These objects are specified as the targets and sources of messages.
When creating a destination resource, you create two objects:
A physical destination
A destination resource that refers to the physical destination using the JNDI name
A JMS application normally uses at least one connection factory and at least one destination.
The order in which the resources are created does not matter.
To create a JMS resource:
Go to File > New (Ctrl-N).
In the Project drop-down list, choose either your EJB module or Web module.
Select GlassFish in the Categories pane, JMS Resource in the File Types pane, and click Next.
(required) Enter a JNDI name for the resource. JMS administered objects are usually placed within the jms naming subcontext (for example, jms/MyMessageSource).
Enable or disable the resource by choosing true or false.
Enter a description.
To create a destination resource, choose one of the following admin object resource types:
javax.jms.Queue - used for point-to-point communication
javax.jms.Topic - used for publish-subscribe communication
To create a connection factory, choose one of the following connector resource types:
javax.jms.QueueConnectionFactory - used for point-to-point communication
javax.jms.TopicConnectionFactory - used for publish-subscribe communication
javax.jms.ConnectionFactory - used for point-to-point communication
With the introduction of the JMS 1.1 specification, it is recommended that you use javax.jms.ConnectionFactory
if you do not need to support existing code.
Click Next.
Enter properties for the resource, if any.
Click Finish.
When you complete the wizard, the resource properties are added to sun-resources.xml.
If you need to edit the properties of the resource, you can open sun-resources.xml in the Source Editor by expanding the
Server Resources node of your project in the Projects window and double-clicking the file.
Once you have created the object in your project, the resource needs to be registered with the server before you can use it.
The resource is automatically registered when you deploy your project.
Connector Resources
When you register JMS resources, the IDE automatically registers connector resources.
A connector resource is a program object that provides an
application with a connection to an EIS. Multiple connector resources
may specify a single connection pool. Applications locate a connector
resource by doing a look up of the resource using its JNDI name.
When you create the JMS resources using the wizard, the IDE automatically performs the following tasks:
For each JMS connection factory that you register, the IDE registers a connector connection pool and connector resource.
For each JMS destination you register, the IDE registers an admin object resource.
Connector resources are visible in the Connectors node in the Services window.
For more on these types of communication and other aspects of JMS,
see chapters 30 and 31 in the Java EE 6 Tutorial: