Setting up a JMS Resource on the GlassFish Application Server

See Also

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:

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:

  1. Go to File > New (Ctrl-N).
  2. In the Project drop-down list, choose either your EJB module or Web module.
  3. Select GlassFish in the Categories pane, JMS Resource in the File Types pane, and click Next.
  4. (required) Enter a JNDI name for the resource. JMS administered objects are usually placed within the jms naming subcontext (for example, jms/MyMessageSource).
  5. Enable or disable the resource by choosing true or false.
  6. Enter a description.
  7. To create a destination resource, choose one of the following admin object resource types: To create a connection factory, choose one of the following connector resource types:
  8. Click Next.
  9. Enter properties for the resource, if any.
  10. 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:

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:

See Also
Registering a Resource with the GlassFish Application Server
About Message-Driven Beans

Legal Notices