Part I Development Tasks and Tools
1. Setting Up a Development Environment
3. Using Ant with Enterprise Server
Part II Developing Applications and Application Components
7. Using the Java Persistence API
8. Developing Web Applications
9. Using Enterprise JavaBeans Technology
10. Using Container-Managed Persistence
13. Developing Lifecycle Listeners
Part III Using Services and APIs
14. Using the JDBC API for Database Access
15. Using the Transaction Service
16. Using the Java Naming and Directory Interface
17. Using the Java Message Service
Message Queue Resource Adapter
Administration of the JMS Service
Checking Whether the JMS Provider Is Running
Creating Physical Destinations
Creating JMS Resources: Destinations and Connection Factories
Restarting the JMS Client After JMS Configuration
Transactions and Non-Persistent Messages
Using the ConfigurableTransactionSupport Interface
Authentication With ConnectionFactory
Message Queue varhome Directory
Delivering SOAP Messages Using the JMS API
To Send SOAP Messages Using the JMS API
To configure the JMS Service and prepare JMS resources for use in applications deployed to the Enterprise Server, you must perform these tasks:
For more information about JMS administration tasks, see Chapter 19, Administering the Java Message Service (JMS) , in Sun GlassFish Enterprise Server v3 Administration Guide and the
Sun GlassFish Message Queue 4.4 Administration Guide.
The JMS Service configuration is available to all inbound and outbound connections pertaining to the Enterprise Server instance. You can edit the JMS Service configuration in the following ways:
To edit the JMS Service configuration using the Administration Console, open the Java Message Service component under the relevant configuration. For details, click the Help button in the Administration Console.
To configure the JMS service, use the asadmin set command to set the following attributes:
server.jms-service.init-timeout-in-seconds = 60 server.jms-service.type = EMBEDDED server.jms-service.start-args = server.jms-service.default-jms-host = default_JMS_host server.jms-service.reconnect-interval-in-seconds = 60 server.jms-service.reconnect-attempts = 3 server.jms-service.reconnect-enabled = true server.jms-service.addresslist-behavior = random server.jms-service.addresslist-iterations = 3 server.jms-service.mq-scheme = mq server.jms-service.mq-service = jms
You can also set these properties:
server.jms-service.property.instance-name = imqbroker server.jms-service.property.instance-name-suffix = server.jms-service.property.append-version = false server.jms-service.property.user-name = server.jms-service.property.password =
You can use the asadmin get command to list all the JMS service attributes and properties. For details, see the Sun GlassFish Enterprise Server v3 Reference Manual.
You can override the JMS Service configuration using JMS connection factory settings. For
details, see Chapter 19, Administering the Java Message Service (JMS) , in Sun GlassFish Enterprise Server v3 Administration Guide.
Note - The Enterprise Server instance must be restarted after configuration of the JMS Service.
A JMS host refers to a Sun GlassFish Message Queue broker. A default JMS host for the JMS service is provided, named default_JMS_host. This is the JMS host that the Enterprise Server uses for performing all Message Queue broker administrative operations, such as creating and deleting JMS destinations.
If you have created a multi-broker cluster in the Message Queue software, delete
the default JMS host, then add the Message Queue cluster’s brokers as JMS
hosts. In this case, the default JMS host becomes the first JMS host
in the AddressList. For more information about the AddressList, see JMS Connection Features. You can
also explicitly set the default JMS host; see
Configuring the JMS Service.
When the Enterprise Server uses a Message Queue cluster, it executes Message Queue specific commands on the default JMS host. For example, when a physical destination is created for a Message Queue cluster of three brokers, the command to create the physical destination is executed on the default JMS host, but the physical destination is used by all three brokers in the cluster.
You can create additional JMS hosts in the following ways:
Use the Administration Console. Open the Java Message Service component under the relevant configuration, then select the JMS Hosts component. For details, click the Help button in the Administration Console.
Use the asadmin create-jms-host command. For details, see the Sun GlassFish Enterprise Server v3 Reference Manual.
For machines having more than one host, use the Host field in the Administration Console or the -–mqhost option of create-jms-host to specify the address to which the broker binds.
You can use the asadmin jms-ping command to check whether a Sun GlassFish Message Queue
instance is running. For details, see the Sun GlassFish Enterprise Server v3 Reference Manual.
Produced messages are delivered for routing and subsequent delivery to consumers using physical destinations in the JMS provider. A physical destination is identified and encapsulated by an administered object (a Topic or Queue destination resource) that an application component uses to specify the destination of messages it is producing and the source of messages it is consuming.
If a message-driven bean is deployed and the Queue physical destination it listens to doesn’t exist, the Enterprise Server automatically creates the physical destination. However, it is good practice to create the Queue physical destination beforehand.
You can create a JMS physical destination in the following ways:
Use the Administration Console. Open the Resources component, open the JMS Resources component, then select Physical Destinations. For details, click the Help button in the Administration Console.
Use the asadmin create-jmsdest command. This command acts on the default JMS host of its target. For details, see the Sun GlassFish Enterprise Server v3 Reference Manual.
To purge all messages currently queued at a physical destination, use the asadmin flush-jmsdest
command. This deletes the messages before they reach any message consumers. For details, see
the Sun GlassFish Enterprise Server v3 Reference Manual.
To create a destination resource, see Creating JMS Resources: Destinations and Connection Factories.
You can create two kinds of JMS resources in the Enterprise Server:
Connection Factories – administered objects that implement the ConnectionFactory, QueueConnectionFactory, or TopicConnectionFactory interfaces.
Destination Resources – administered objects that implement the Queue or Topic interfaces.
In either case, the steps for creating a JMS resource are the same. You can create a JMS resource in the following ways:
To create a JMS resource using the Administration Console, open the Resources component, then open the JMS Resources component. Click Connection Factories to create a connection factory, or click Destination Resources to create a queue or topic. For details, click the Help button in the Administration Console.
A JMS resource is a type of connector. For more information about connectors, see Chapter 12, Developing Connectors.
Note - All JMS resource properties that used to work with version 7 of the Enterprise Server are supported for backward compatibility.