blob: c8ff738485f49b6be71b1e128c9d519326fff6cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package examples.messaging;
import javax.jms.*;
import javax.ejb.*;
import javax.annotation.PreDestroy;
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Topic")
})
public class LogBean implements MessageListener {
public LogBean() {
System.out.println("LogBean created");
}
public void onMessage(Message msg) {
if (msg instanceof TextMessage) {
TextMessage tm = (TextMessage) msg;
try {
String text = tm.getText();
System.out.println("Received new message : " + text);
} catch (JMSException e) {
e.printStackTrace();
}
}
}
@PreDestroy
public void remove() {
System.out.println("LogBean destroyed.");
}
}
|