|
|
| WebLogic Server 7.0 Code Examples, BEA Systems, Inc. |
Package examples.jms.topic
This example shows how to establish a connection to a JMS topic, and send
and receive messages from that topic.
See:
Description
|
Class Summary |
| TopicReceive |
This example shows how to establish a connection to and receive
messages from a JMS topic. |
| TopicSend |
This examples shows how to establish a connection and send messages to the
JMS topic. |
Package examples.jms.topic Description
This example shows how to establish a connection to a JMS topic, and send
and receive messages from that topic. The classes in this package operate
on the same JMS topic. Run the classes together to observe messages being
sent and received.
The following sections describe how to:
-
Build the example
-
Configure the example
-
Run the example
Build the Example
-
Set up your development shell, as described in Setting
up your environment.
-
Compile the example by executing the following command or by executing
the build script provided
for this example in the SAMPLES_HOME\server\src\
examples\jms\topic directory, where SAMPLES_HOME refers to the directory for all samples and examples for the
WebLogic Platform.
The script will compile the Topic example, as shown in this example for a Windows systems:
prompt> javac -d %CLIENT_CLASSES% *.java
and copies the files to the following directory:
SAMPLES_HOME\server\stage\examples\clientclasses\examples\jms\topic
Configure the Example
-
Start the server with the examples
configuration.
-
Bring up the Administration Console
in your browser.
-
Click to expand the JMS node in the left pane.
-
Click to expand the JMS Connection Factories node in the left pane.
-
Choose the server target for the exampleTopic connection factory as follows:
-
Select the exampleTopic node. The exampleTopic connection factory configuration
information displays in the right pane.
-
Select the Targets tab in the right pane to display the Available and Chosen
targets.
-
Move the examplesServer target to the Chosen column and click the Apply
button to save the assignment.
Note: Normally, you would also have to choose one or more targets
for the JMS server associated with the topic. For your convenience, the
examplesJMSServer server has been preconfigured to include the examplesServer
as a chosen target.
Run the Example
-
With the server running, set
up a new development shell and run the TopicReceive
client with the following command:
prompt> java examples.jms.topic.TopicReceive t3://hostname:port
where:
-
hostname
-
Host name of the WebLogic Server.
-
port
-
Port where the WebLogic Server is listening for connections.
-
To observe messages being sent to mutliple topic subscribers, set
up a new development shell and run the TopicReceive
client, as described in the previous step.
-
To send messages to the topic, set
up a new development shell and run the TopicSend
client
with the following command:
prompt> java examples.jms.topic.TopicSend t3://hostname:port
where:
-
hostname
-
Host name of the WebLogic Server.
-
port
-
Port where the WebLogic Server is listening for connections.
-
To end the program, send a quit message from the shell running
the TopicSend
client.
There's More...
For more information, refer to Programming
WebLogic JMS.
Copyright © 2002 BEA Systems, Inc. All Rights Reserved.