Jakarta ee @TransactionAttribute有什么用途
在下面的MDB代码片段中,Jakarta ee @TransactionAttribute有什么用途,jakarta-ee,transactions,ibm-mq,message-driven-bean,Jakarta Ee,Transactions,Ibm Mq,Message Driven Bean,在下面的MDB代码片段中,@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.Messa
@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();
}
}
}
您包含的代码段表示MDB的声明性事务配置,它告诉容器应该如何管理此MDB的事务 我找不到比java transaction design strategy book中的引用更好的解释该属性的方法: NotSupported属性(Spring中不支持传播)告诉容器所调用的方法不使用事务。如果事务已经启动,它将被挂起,直到方法完成。如果不存在任何事务,容器将调用该方法而不启动事务