MessageSenderImpl.jcs Sample
This topic inludes the source code for the MessageSenderImpl.jcs Sample.
Sample Location
This sample is located in the following directory in your WebLogic Workshop installation:
BEA_HOME/weblogic81/samples/workshop/SamplesApp/EJBs_ClientApps/messageDriven/
Sample Source Code
01 package messageDriven;
02
03 import com.bea.control.*;
04 import javax.jms.JMSException;
05 import javax.jms.MapMessage;
06 /**
07 * @editor-info:code-gen control-interface="true"
08 */
09 public class MessageSenderImpl implements MessageSender, ControlSource
10 {
11 /**
12 * @common:control
13 */
14 private messageDriven.sendToQueueControl queueSend;
15
16 /**
17 * @common:control
18 */
19 private messageDriven.sendToTopicControl topicSend;
20
21 static final long serialVersionUID = 1L;
22
23 /**
24 * @common:operation
25 * @common:message-buffer enable="true"
26 */
27 public void add20ViaQueue(int currentNum) throws JMSException
28 {
29 String name;
30 for(int i = 0; i < 20; i++) {
31 MapMessage msg = queueSend.getSession().createMapMessage();
32 msg.setStringProperty("Command", "Add");
33 name = Integer.toString(currentNum + i);
34 msg.setString("tokenName", name);
35 queueSend.sendJMSMessage(msg);
36 }
37 }
38
39 /**
40 * @common:operation
41 * @common:message-buffer enable="true"
42 */
43 public void add20ViaTopic(int currentNum) throws JMSException
44 {
45 String name;
46
47 for(int i = 0; i < 20; i++) {
48 name = Integer.toString(currentNum + i);
49 topicSend.sendTextMessage(name);
50 }
51 }
52
53 /**
54 * @common:operation
55 * @common:message-buffer enable="true"
56 */
57 public void deleteAllViaQueue() throws JMSException
58 {
59 MapMessage msg = queueSend.getSession().createMapMessage();
60 msg.setStringProperty("Command", "Delete");
61 queueSend.sendJMSMessage(msg);
62 }
63 }
|