2

In below MDB code fragment which will be deployed in JBoss and IBM MQ as the message provider, what is the use of @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) annotation? Why is it kept on class level?

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();
        }
    }
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Pramod Kumar
  • 43
  • 2
  • 9

1 Answers1

0

The snippet you included represent a declarative transactions config for MDB wich tell the container how it should manage the transaction for this MDB.

I can't find better explication of this attribute more then the quote from java transaction design strategy book :

The NotSupported attribute (PROPAGATION_NOT_SUPPORTED in Spring) tells the container that the method being invoked does not use a transaction. If a transaction has already been started it will be suspended until the method completes. If no transaction exists the container will invoke the method without starting a transaction

elmehdi
  • 449
  • 2
  • 10