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 42 43 public class ExQueueBean implements MessageDrivenBean , MessageListener 44 { 45 46 org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(getClass()); 47 48 private MessageDrivenContext ctx = null; 49 50 public ExQueueBean() 51 { 52 53 } 54 55 @Resource 56 public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException 57 { 58 this.ctx = ctx; 59 } 60 61 public void ejbCreate() 62 { 63 } 64 65 public void ejbRemove() 66 { 67 ctx = null; 68 } 69 70 public void onMessage(Message message) 71 { 72 log.debug("ExQueueBean rolling back transaction" + message.toString()); 73 ctx.setRollbackOnly(); 74 try 75 { 76 TestStatusBean.addDestination(message.getJMSDestination()); 77 } 78 catch(JMSException e) 79 { 80 e.printStackTrace(); 81 } 82 } 83 } 85 | Popular Tags |