1 23 package bridge; 24 25 import javax.jms.*; 26 27 30 public class MsgListener implements MessageListener { 31 String who; 32 33 public MsgListener(String who) { 34 this.who = who; 35 } 36 37 public void onMessage(Message msg) { 38 try { 39 if (msg instanceof TextMessage) 40 System.out.println(who + " receive : " + ((TextMessage) msg).getText()); 41 } 42 catch (JMSException exc) { 43 System.err.println("Exception in listener: " + exc); 44 } 45 } 46 } 47 | Popular Tags |