1 22 package org.jboss.ejb3.test.dd.mdb; 23 24 import javax.annotation.Resource; 25 import javax.ejb.MessageDrivenBean ; 26 import javax.ejb.MessageDrivenContext ; 27 import javax.ejb.EJBException ; 28 29 import javax.jms.JMSException ; 30 import javax.jms.MessageListener ; 31 import javax.jms.Message ; 32 33 import org.jboss.logging.Logger; 34 35 44 45 public class TopicBean implements MessageDrivenBean , MessageListener 46 { 47 private static final Logger log = Logger.getLogger(TopicBean.class); 48 49 private MessageDrivenContext ctx = null; 50 51 public TopicBean() 52 { 53 54 } 55 56 @Resource 57 public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException 58 { 59 this.ctx = ctx; 60 } 61 62 public void ejbCreate() 63 { 64 } 65 66 public void ejbRemove() 67 { 68 ctx = null; 69 } 70 71 public void onMessage(Message message) 72 { 73 if (ctx.getRollbackOnly()) 74 throw new IllegalStateException ("Error in transaction"); 75 log.debug("DEBUG: TopicBean got message" + message.toString()); 76 try 77 { 78 TestStatusBean.addDestination(message.getJMSDestination()); 79 } 80 catch(JMSException e) 81 { 82 e.printStackTrace(); 83 } 84 85 } 86 } 88 | Popular Tags |