The Java EE 7 Tutorial
46.9 Using NetBeans IDE to Create JMS Resources
When you write your own JMS applications, you will need to create resources for them. This section explains how to use NetBeans IDE to create src/main/setup/glassfish-resources.xml
files similar to those used in the examples in this chapter. It also explains how to use NetBeans IDE to delete the resources.
You can also create, list, and delete JMS resources using the Administration Console or the asadmin create-jms-resource
, asadmin list-jms-resources
, and asadmin delete-jms-resources
commands. For information, consult the GlassFish Server documentation or enter asadmin help
command-name.
46.9.1 To Create JMS Resources Using NetBeans IDE
Follow these steps to create a JMS resource in GlassFish Server using NetBeans IDE. Repeat these steps for each resource you need.
-
Right-click the project for which you want to create resources and select New, then select Other.
-
In the New File wizard, under Categories, select GlassFish.
-
Under File Types, select JMS Resource.
-
On the General Attributes - JMS Resource page, in the JNDI Name field, enter the name of the resource.
By convention, JMS resource names begin with
jms/
. -
Select the option for the resource type.
Normally, this is either
javax.jms.Queue
,javax.jms.Topic
, orjavax.jms.ConnectionFactory
. -
Click Next.
-
On the JMS Properties page, for a queue or topic, enter a name for a physical queue in the Value field for the Name property.
You can enter any value for this required field.
Connection factories have no required properties. In a few situations, you may need to specify a property.
-
Click Finish.
A file named
glassfish-resources.xml
is created in your Maven project, in a directory namedsrc/main/setup/
. In the Projects tab, you can find it under the Other Sources node. You will need to run theasadmin add-resources
command to create the resources in GlassFish Server.
46.9.2 To Delete JMS Resources Using NetBeans IDE
-
In the Services tab, expand the Servers node, then expand the GlassFish Server node.
-
Expand the Resources node, then expand the Connector Resources node.
-
Expand the Admin Object Resources node.
-
Right-click any destination you want to remove and select Unregister.
-
Expand the Connector Connection Pools node.
-
Right-click the connection pool that corresponds to the connection factory you removed and select Unregister.
When you remove a connector connection pool, the associated connector resource is also deleted. This action removes the connection factory.