1 package example; 2 3 import java.util.logging.Logger ; 4 import java.util.logging.Level ; 5 6 import javax.jms.Message ; 7 import javax.jms.TextMessage ; 8 import javax.jms.MessageListener ; 9 10 public class MyListener implements MessageListener { 11 private static final Logger log = Logger.getLogger(MyListener.class.getName()); 12 private static String _lastMessage; 13 14 17 public static String getLastMessage() 18 { 19 return _lastMessage; 20 } 21 22 25 public void onMessage(Message message) 26 { 27 try { 28 TextMessage textMessage = (TextMessage ) message; 29 30 log.info("received: " + textMessage.getText()); 31 32 _lastMessage = textMessage.getText(); 33 } catch (Throwable e) { 34 log.log(Level.WARNING, e.toString(), e); 35 } 36 } 37 } 38 | Popular Tags |