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 Sun Resources 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
Click Next.
Enter properties for the resource, if any.
Click Finish.
Once you have created the object in your project, you need to register the
resource with the server.
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 register or delete JMS resources, 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.
When you delete a JMS resources, the corresponding connector resources are automatically deleted.
Connector resources are visible in the Connectors node in the Runtime window.
For more on these types of communication and other aspects of JMS,
see the Chapter 32 The Java Message Service in the Java EE 5 Tutorial: