下午看着教学视频学习JMS,其实到也不是很难,一些框架是固定的,但是,我遇到的问题却让我很头疼。
在下面的代码中,其实是有错的,关于注解,一直无法认识ActivationConfigProperty,不能自动添加包了。我就上网找啊,就是找不到是怎么回事,最后没办法了,自己写上吧import
javax.ejb.ActivationConfigProperty;竟然就好了,真是气人啊,害得我好苦,这么大半天就找这个事了。看来这编辑器的智能提示功能还不是那么靠得住的,还得自己动手写写,毕竟人家也累啊!
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/myqueue") })
public class MyMDB implements MessageListener {
public void onMessage(Message msg) {
try {
TextMessage text=(TextMessage)msg;
System.out.println("Receive message "+text.getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}