Sending a JMS Message
See Also
A Java Message Service (JMS) message is an object that communicates information
between JMS clients. The message is sent from one client to a second client
that listens for messages through a JMS destination on an application server.
In the IDE, you can automatically generate code to send a JMS message to any
message-driven bean in an open project.
To send a JMS message:
- (Optional) Create a service locator class to handle getting the reference
to the database.
- Open the Java file from which you want to send the JMS message. The file
must be in an EJB module project or a standard web application project. You
cannot generate lookup code in a free-form web application project.
- In the Source Editor, right-click in the file and choose Insert Code
> Send JMS Message.
- Select the message-driven bean that is the destination for the message.
You can switch between open projects using the Project drop-down menu.
- Under Service Locator Strategy, specify whether to generate inline lookup
code or use an existing service locator. You can click the Browse to search
for the service locator class name.
- Click OK.
The IDE creates two methods:
- createJMSMessageForNewMessageDestination. The
method that creates the message that is sent. You should implement your
business logic in this method.
- sendJMSMessageToNewMessageDestination. The method
that handles the message you created in the method above. You should not
modify this message.
The IDE also registers the resource reference and message destination reference
in your module's general deployment descriptor.
- If your project's target server is the GlassFish/Sun Java System Application Server,
the IDE automatically configures a destination and connection factory for
the message-driven bean when you create the bean. If you are deploying to
a different application server, you have to configure the server-specific
deployment descriptors and the server resources yourself.
- See Also
- About Message-Driven
Beans
- Using a Service Locator
- Setting up a JMS Resource on the GlassFish Application Server
Legal Notices