📄 logbean.java
字号:
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.");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -