1 22 package org.jboss.ejb3.test.mdb; 23 24 import javax.ejb.ActivationConfigProperty ; 25 import javax.ejb.MessageDriven ; 26 import javax.ejb.MessageDrivenContext ; 27 import javax.jms.Message ; 28 import javax.jms.MessageListener ; 29 import javax.jms.DeliveryMode ; 30 31 import javax.annotation.security.RunAs; 32 import javax.annotation.Resource; 33 34 import org.jboss.annotation.security.SecurityDomain; 35 import org.jboss.logging.Logger; 36 37 43 @MessageDriven (activationConfig = 44 { 45 @ActivationConfigProperty (propertyName="destinationType", propertyValue="javax.jms.Queue"), 46 @ActivationConfigProperty (propertyName="destination", propertyValue="queue/nondurablemdbtest"), 47 @ActivationConfigProperty (propertyName="subscriptionDurability", propertyValue="NON_DURABLE") 48 }) 49 @RunAs("TestRole") 50 @SecurityDomain("other") 51 public class NondurableQueueTestMDB implements MessageListener 52 { 53 private static final Logger log = Logger.getLogger(NondurableQueueTestMDB.class); 54 @Resource MessageDrivenContext ctx; 55 56 public void onMessage(Message recvMsg) 57 { 58 if (ctx == null) throw new RuntimeException ("FAILED ON CTX LOOKUP"); 59 try 60 { 61 System.out.println("*** NondurableQueueTestMDB onMessage"); 62 if (recvMsg.getJMSDeliveryMode() != DeliveryMode.NON_PERSISTENT) 63 log.error("Message is PERSISTENT - should be NON PERSISTENT"); 64 else 65 TestStatusBean.nondurableQueueRan++; 66 } 67 catch (Exception e) 68 { 69 e.printStackTrace(); 70 } 71 } 72 } 73 | Popular Tags |