【发布时间】:2018-08-03 04:34:42
【问题描述】:
下面的MDB代码片段将作为消息提供者部署在JBoss和IBM MQ中,@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)有什么用
注解?为什么要保持在班级级别?
import javax.ejb.*;
import javax.jms.Message;
import javax.jms.TextMessage;
import javax.jms.JMSException;
import javax.ejb.MessageDriven;
import javax.jms.MessageListener;
import javax.ejb.ActivationConfigProperty;
import org.jboss.ejb3.annotation.ResourceAdapter;
@MessageDriven( name="MyMDB",
activationConfig =
{
@ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
@ActivationConfigProperty(propertyName = "hostName", propertyValue = "MQ.HOST.NAME"),
@ActivationConfigProperty(propertyName = "port", propertyValue = "MQ.PORT"),
@ActivationConfigProperty(propertyName = "channel", propertyValue = "MQ.CHANNEL.NAME"),
@ActivationConfigProperty(propertyName = "queueManager", propertyValue = "MQ.QUEUE.MANAGER"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "MQ.QUEUE.NAME"),
@ActivationConfigProperty(propertyName = "transportType", propertyValue = "MQ.CLIENT")
})
@ResourceAdapter(value = "wmq.jmsra.rar")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class MyMDB implements MessageListener{
public void onMessage(Message message) {
TextMessage textMessage = (TextMessage) message;
try {
System.out.println("nnt Message Received by MDB : "+ textMessage.getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}
【问题讨论】:
标签: jakarta-ee transactions ibm-mq message-driven-bean