AccountPublish.jws Sample

A web service that demonstrates use of a JMS control to publish messages to a JMS topic. AccountSubscribe.jws is a companion to this sample.

Concepts Demonstrated by this Sample

Location of Sample Files

This sample is located in the jms folder of the samples WebLogic Workshop project. In the file system the location is:

BEA_HOME\weblogic700\samples\workshop\applications\samples\jms\AccountPublish.jws

How to Run the Sample

The AccountPublish.jws and AccountSubscribe.jws samples work together. The instructions below describe how to use both services:

  1. Start WebLogic Server in the appropriate domain.

    • On Microsoft Windows systems, From the Start menu navigate to:

    BEA WebLogic E-business Platform->BEA WebLogic Platform 7.0->WebLogic Workshop Samples->Start Samples Server.

    • On Linux or Solaris systems, run:

    BEA_HOME/weblogic700/samples/workshop/startWebLogic.sh

  2. In a browser (not from the WebLogic Workshop visual development environment), navigate to http://localhost:7001/samples/jms/AccountSubscribe.jws. If WebLogic Server is running in the appropriate domain on this machine, you may click here to run AccountSubscribe.jws.

  3. Navigate to the Test Formtab of Test View, if necessary.

  4. Invoke the startListening method. The AccountSubscribe.jws web service is now listening for messages that are published to a JMS topic named jms.AccountUpdate.

  5. Launch the AccountPublish.jws service either by opening it in WebLogic Workshop and selecting the Start operation or by entering http://localhost:7001/samples/jms/AccountPublish.jws in the address bar of your browser. If WebLogic Server is running in the appropriate domain on this machine, you may click here to run AccountPublish.jws.

  6. Navigate to the Test Form tab of Test View, if necessary.

  7. Enter a string value for accountID and numeric value for amount and invoke the deposit method. At this point a message is published to the jms.AccountUpdate JMS topic.

  8. In the browser that is testing AccountSubscribe.jws, select "Refresh".

  9. You should see that the accountUpdateReceived callback has been sent to the client.

  10. Select the accountUpdateReceived log entry to see the payload of the callback. It should contain the same information you entered for the deposit method in Step 7.

The message containing the account transaction was published to the topic by the AccountPublishJMSControl.ctrl JMS control used by AccountPublish.jws. The JMS server then sent the message to all active subscribers. Since AccountSubscribe.jws is subscribed to the topic via the AccountSubscribeJMSControl.ctrl JMS control, it receives the message. If you examine the two CTRL files, you will see that the information you entered was encoded in both the message properties and the message body using the @jws:jms-property and @jws:jms-header properties of the JMS controls. When using JMS messaging, the senders and receivers of messages must agree on the message format at design time.

Related Topics

Controls: Using Resources from a Web Service

JMS Control: Using Java Message Service Queues and Topics from Your Web Service

Maintaining State with Conversations

AccountSubscribe.jws Sample

CustomJMSClient.jws Sample

SimpleJMS.jws Sample

Test View