SimpleJMS.jws Sample
This topic inludes the source code for the SimpleJMS.jws Sample.
Sample Location
This sample is located in the following directory in your WebLogic Workshop installation:
BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/jms/
Sample Source Code
01 package jms;
02
03 /**
04 * <p>This web service shows the use of a simple jms control.</p>
05 *
06 * <p>It uses the same queue for send and receive, so it will send messages to
07 * itself. The queue used by this sample is preconfigured in the cg domain
08 * when WebLogic Server is installed.</p>
09 *
10 * <p>"sendString" will publish a text message to the send queue.</p>
11 *
12 * <p>"onTextMessage" will receive the message from the receive queue
13 * (in this case, the message just sent from publish). </p>
14 * @common:target-namespace namespace="http://workshop.bea.com/SimpleJMS"
15 */
16 public class SimpleJMS implements com.bea.jws.WebService
17 {
18 /**
19 * @common:control
20 */
21 private jms.SimpleJMSControl myJMSControl;
22
23 private String name;
24
25 public Callback callback;
26
27 public interface Callback {
28 public void onMessageReceived(String msg);
29 }
30
31 /**
32 * <p>Starts an instance of the service and assigns a name to it.
33 *
34 * @common:operation
35 * @jws:conversation phase="start"
36 */
37 public void start(String name) {
38 this.name = name;
39 }
40
41 /**
42 * <p>Finishes this conversation instance.
43 *
44 * @common:operation
45 * @jws:conversation phase="finish"
46 */
47 public void finish() {
48 }
49
50 /**
51 * <p>Submits a string message that is sent to the send queue. In this example
52 * it will immediately arrive on the receive queue.</p>
53 *
54 * @common:operation
55 * @jws:conversation phase="continue"
56 */
57 public void sendString(String msg) throws Exception {
58 myJMSControl.publishText(msg);
59 }
60
61 public void myJMSControl_onTextMessage(String msg) {
62 callback.onMessageReceived("[" + name + "] Your message is: " + msg );
63 }
64
65 }
|