1 25 26 package org.objectweb.easybeans.examples.messagedrivenbean; 27 28 import javax.ejb.ActivationConfigProperty ; 29 import javax.ejb.MessageDriven ; 30 import javax.jms.JMSException ; 31 import javax.jms.Message ; 32 import javax.jms.MessageListener ; 33 import javax.jms.TextMessage ; 34 35 40 @MessageDriven (activationConfig = { 41 @ActivationConfigProperty (propertyName = "destination", propertyValue = "SampleQueue"), 42 @ActivationConfigProperty (propertyName = "destinationType", propertyValue = "javax.jms.Queue") 43 } 44 ) 45 public class MessageDrivenBean implements MessageListener { 46 47 51 public void onMessage(final Message message) { 52 String txt = "Receiving a message named '" + message + "'."; 53 if (message instanceof TextMessage ) { 55 try { 56 txt += " with the content '" + ((TextMessage ) message).getText(); 57 } catch (JMSException e) { 58 System.err.println("Error while getting the content of the message"); 59 e.printStackTrace(); 60 } 61 } 62 System.out.println(txt); 63 } 64 65 } 66 | Popular Tags |