1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.jboss.as.quickstarts.cmt.mdb;
18
19 import java.util.logging.Logger;
20
21 import javax.ejb.ActivationConfigProperty;
22 import javax.ejb.MessageDriven;
23 import javax.jms.JMSException;
24 import javax.jms.Message;
25 import javax.jms.MessageListener;
26 import javax.jms.TextMessage;
27
28
29
30
31
32
33
34
35
36 @MessageDriven(name = "HelloWorldMDB", activationConfig = {
37 @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
38 @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/CMTQueue"),
39 @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
40 public class HelloWorldMDB implements MessageListener {
41
42 private final static Logger LOGGER = Logger.getLogger(HelloWorldMDB.class.toString());
43
44
45
46
47 public void onMessage(Message rcvMessage) {
48 TextMessage msg = null;
49 try {
50 if (rcvMessage instanceof TextMessage) {
51 msg = (TextMessage) rcvMessage;
52 LOGGER.info("Received Message: " + msg.getText());
53 } else {
54 LOGGER.warning("Message of wrong type: " + rcvMessage.getClass().getName());
55 }
56 } catch (JMSException e) {
57 throw new RuntimeException(e);
58 }
59 }
60 }