|
|
| WebLogic Server 7.0 Code Examples, BEA Systems, Inc. |
Package examples.jms.queue
This example shows how to establish a connection to a JMS queue, and send,
browse, and receive messages from that queue.
See:
Description
|
Class Summary |
| QueueBrowse |
This example shows how to establish a connection to a JMS
queue and browse (but not dequeue) the queued messages. |
| QueueReceive |
This example shows how to establish a connection to
and receive messages from a JMS queue. |
| QueueReceiveInTx |
This example shows how to establish a connection to
and receive messages from a JMS queue in a client-demarcated
transaction. |
| QueueSend |
This example shows how to establish a connection
and send messages to the JMS queue. |
Package examples.jms.queue Description
This example shows how to establish a connection to a JMS queue, and send,
browse, and receive messages from that queue. The classes in this package
operate on the same JMS queue. Run the classes together to observe messages
being sent and received, and to browse the queue for messages.
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\queue directory, where SAMPLES_HOME refers to the directory for all samples and examples for the
WebLogic Platform.
The script will compile the Queue 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\queue
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.
-
Select the exampleQueue node.
The exampleQueue connection factory configuration information displays in the
right pane.
-
Select the Transactions tab in the right pane to display the transaction options.
-
Select the User Transactions Enabled check box.
-
Click Apply to save the change.
-
Choose the server target for the exampleQueue connection factory as follows:
-
Select the Targets tab in the right pane to display the Available and Chosen
targets.
-
Move the examplesServer target to the Chosen column.
-
Click Apply to save the assignment.
Note: Normally, you would also have to choose one or more targets for the JMS server
associated with the queue.
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
QueueSend client with the following command:
$ java examples.jms.queue.QueueSend t3://hostname:port
where:
- hostname
- Host name of the WebLogic Server.
- port
- Port where the WebLogic Server is listening for connections.
-
Using the QueueSend client,
send messages to the queue.
-
To browse messages in the queue,
set up a new development shell
and run the
QueueBrowse client with the following command:
$ java examples.jms.queue.QueueBrowse t3://hostname:port
where:
- hostname
- Host name of the WebLogic Server.
- port
- Port where the WebLogic Server is listening for connections.
-
To receive messages from the queue,
set up a new development shell
and run the QueueReceive client
with the following command:
$ java examples.jms.queue.QueueReceive t3://hostname:port
where:
- hostname
- Host name of the WebLogic Server.
- port
- Port where the WebLogic Server is listening for connections.
-
To receive messages from the queue in a client-demarcated transaction,
set up a new development shell
and run the QueueReceiveInTx
client with the following command:
$ java examples.jms.queue.QueueReceiveInTx t3://hostname:port
where:
- hostname
- Host name of the WebLogic Server.
- port
- Port where the WebLogic Server is listening for connections.
The program displays messages as they are received from the queue.
-
To end the program, send a quit message from the shell running
the QueueSend client.
There's More...
For more information on WebLogic JMS, refer to Programming
WebLogic JMS.
Copyright © 2002 BEA Systems, Inc. All Rights Reserved.