AccountSubscribe.jws Sample

A web service that demonstrates use of a JMS control to subscribe to a JMS topic. AccountPublish.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 WebServices project in the SamplesApp sample application. In the file system the location is:

BEA_HOME\weblogic81\samples\workshop\SamplesApp\WebServices\jms\AccountSubscribe.jws

To Run the Sample

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

  1. Start WebLogic Server in the appropriate domain.
  2. Launch the AccountSubscribe.jws service either by opening it in WebLogic Workshop and selecting the Start operation or by entering http://localhost:7001/WebServices/jms/AccountSubscribe.jws in the address bar of your browser. If WebLogic Server is running in the appropriate domain on this machine and you have deployed the SamplesApp sample application, you may click here to run AccountSubscribe.jws.
  3. Navigate to the Test Form tab 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 by by entering http://localhost:7001/WebServices/jms/AccountPublish.jws in the address bar of your browser (not from the WebLogic Workshop visual development environment). If WebLogic Server is running in the appropriate domain on this machine and you have deployed the SamplesApp sample application, 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. A message is published to the jms.AccountUpdate JMS topic.
  8. In the browser that is testing AccountSubscribe.jws, click 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.jcx 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.jcx JMS control, it receives the message. If you examine the two JCX files, you will see that the information you entered was encoded in both the message properties and the message body using the @jc:jms-property and @jc: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

Using WebLogic Built-In Controls

JMS Control

AccountPublish.jws Sample

CustomJMSClient.jws Sample

SimpleJMS.jws Sample

Test View