1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.jms;
17
18 import javax.jms.Destination;
19 import javax.jms.JMSException;
20 import javax.jms.Message;
21
22 import org.apache.commons.jelly.JellyTagException;
23 import org.apache.commons.jelly.XMLOutput;
24
25 /*** Sends a JMS message to some destination.
26 *
27 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
28 * @version $Revision: 155420 $
29 */
30 public class SendTag extends MessageOperationTag {
31
32 /*** The JMS Message to be sent */
33 private Message message;
34
35 public SendTag() {
36 }
37
38
39
40 public void doTag(XMLOutput output) throws JellyTagException {
41
42 invokeBody(output);
43
44 Message message = getMessage();
45 if ( message == null ) {
46 throw new JellyTagException( "No message specified. Either specify a 'message' attribute or use a nested <jms:message> tag" );
47 }
48
49 try {
50 Destination destination = getDestination();
51 if ( destination == null ) {
52 throw new JellyTagException( "No destination specified. Either specify a 'destination' attribute or use a nested <jms:destination> tag" );
53 }
54 getConnection().send( destination, message );
55 }
56 catch (JMSException e) {
57 throw new JellyTagException(e);
58 }
59 }
60
61
62
63 public Message getMessage() {
64 return message;
65 }
66
67 /***
68 * Sets the JMS message to be sent
69 */
70 public void setMessage(Message message) {
71 this.message = message;
72 }
73 }