1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| *
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ejb;
import javax.annotation.Resource;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.*;
/**
*
* @author laleye
*/
@MessageDriven(mappedName = "jndi.properties", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),
@ActivationConfigProperty(propertyName = "clientId", propertyValue = "NewMessageBean"),
@ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "NewMessageBean")
})
public class MessageBean implements MessageListener {
// @Resource(name="facture.jms")
//private ConnectionFactory connectionFactory;
//@Resource(name="jms/facture.jms")
//private Destination destination;
public MessageBean() {
}
@Override
public void onMessage(Message message) {
TextMessage tm = (TextMessage) message;
try {
String text = tm.getText();
System.out.println("Received new message : " + text);
} catch(JMSException e) {
e.printStackTrace();
}
}
} |
Partager