1 22 package org.jboss.ejb3.test.mdbtransactions; 23 24 import javax.ejb.ActivationConfigProperty ; 25 import javax.ejb.EJB ; 26 import javax.ejb.MessageDriven ; 27 import javax.jms.Message ; 28 import javax.jms.MessageListener ; 29 import javax.jms.ObjectMessage ; 30 import javax.persistence.EntityManager; 31 import javax.persistence.PersistenceContext; 32 33 import org.jboss.logging.Logger; 34 35 38 @MessageDriven (activationConfig = 39 { 40 @ActivationConfigProperty (propertyName="destinationType", propertyValue="javax.jms.Queue"), 41 @ActivationConfigProperty (propertyName="destination", propertyValue="queue/mdbtest") 42 }) 43 public class QueueTestMDB implements MessageListener 44 { 45 private static final Logger log = Logger.getLogger(QueueTestMDB.class); 46 47 private @PersistenceContext EntityManager manager; 48 @EJB StatelessFacade stateless; 49 50 public void onMessage(Message recvMsg) 51 { 52 try 53 { 54 ObjectMessage message = (ObjectMessage )recvMsg; 55 Entity entity = (Entity)message.getObject(); 56 stateless.persist(entity); 57 ++TestStatusBean.messageCount; 58 } 59 catch (Throwable t) 60 { 61 TestStatusBean.caughtRollback = true; 62 } 63 } 64 } 65 | Popular Tags |