[jboss-jira] [JBoss JIRA] (AS7-5625) Transaction propagation to a JMS QueueSender not occuring for CMT

Doug Grove (JIRA) jira-events at lists.jboss.org
Mon Sep 24 17:14:34 EDT 2012


     [ https://issues.jboss.org/browse/AS7-5625?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Grove updated AS7-5625:
----------------------------

    Description: 
This behavior is similiar to AS7-3016.  That case involves UserTransactions, where this involves the SessionContext and container managed transactions.

In the code below:

@Stateless
@LocalBean
public class SenderBean {
    
    private @Resource(mappedName= "java:/JmsXA") 
            ConnectionFactory connectionFactory;
    
    private @Resource(mappedName = "java:/queue/events")
            Queue queue;
    
    private QueueConnection connection;
    private QueueSession session;
    private QueueSender sender = null;
    
    @PostConstruct
    protected void initBean() throws JMSException {
        Logger.getLogger(SenderBean.class.getName()).log(Level.INFO, "Entering/Exiting initBean");
        QueueConnectionFactory qcf = (QueueConnectionFactory)connectionFactory;
        connection = qcf.createQueueConnection();
        session = connection.createQueueSession(true, 0);
//        sender = session.createSender(queue);
    }
    
    @PreDestroy
    protected void disposeBean() {
        Logger.getLogger(SenderBean.class.getName()).log(Level.INFO, "Entering/Exiting dispose");
        try {
            sender.close();
            session.close();
            connection.close();
        } catch (JMSException ex) {
            Logger.getLogger(SenderBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void sendMessage() throws JMSException {
        Logger.getLogger(SenderBean.class.getName()).log(Level.INFO, "Entering/Exiting sendMessage");
  
        if (sender == null)
        	sender = session.createSender(queue);
        ObjectMessage msg = session.createObjectMessage("testMsg");
        sender.send(msg);
    }
}

If "sender" is initialized in the initBean(), then a transaction does not propagate down into the sender.send().  If "sender" is initialized in the sendMessage() method, than a transaction is available.  

Also note that I moved:

@TransactionAttribute(TransactionAttributeType.REQUIRED)

to the class level and the problem persisted.

    
> Transaction propagation to a JMS QueueSender not occuring for CMT
> -----------------------------------------------------------------
>
>                 Key: AS7-5625
>                 URL: https://issues.jboss.org/browse/AS7-5625
>             Project: Application Server 7
>          Issue Type: Feature Request
>          Components: EJB
>    Affects Versions: 7.1.2.Final (EAP)
>            Reporter: Doug Grove
>            Assignee: jaikiran pai
>
> This behavior is similiar to AS7-3016.  That case involves UserTransactions, where this involves the SessionContext and container managed transactions.
> In the code below:
> @Stateless
> @LocalBean
> public class SenderBean {
>     
>     private @Resource(mappedName= "java:/JmsXA") 
>             ConnectionFactory connectionFactory;
>     
>     private @Resource(mappedName = "java:/queue/events")
>             Queue queue;
>     
>     private QueueConnection connection;
>     private QueueSession session;
>     private QueueSender sender = null;
>     
>     @PostConstruct
>     protected void initBean() throws JMSException {
>         Logger.getLogger(SenderBean.class.getName()).log(Level.INFO, "Entering/Exiting initBean");
>         QueueConnectionFactory qcf = (QueueConnectionFactory)connectionFactory;
>         connection = qcf.createQueueConnection();
>         session = connection.createQueueSession(true, 0);
> //        sender = session.createSender(queue);
>     }
>     
>     @PreDestroy
>     protected void disposeBean() {
>         Logger.getLogger(SenderBean.class.getName()).log(Level.INFO, "Entering/Exiting dispose");
>         try {
>             sender.close();
>             session.close();
>             connection.close();
>         } catch (JMSException ex) {
>             Logger.getLogger(SenderBean.class.getName()).log(Level.SEVERE, null, ex);
>         }
>     }
>     
>     @TransactionAttribute(TransactionAttributeType.REQUIRED)
>     public void sendMessage() throws JMSException {
>         Logger.getLogger(SenderBean.class.getName()).log(Level.INFO, "Entering/Exiting sendMessage");
>   
>         if (sender == null)
>         	sender = session.createSender(queue);
>         ObjectMessage msg = session.createObjectMessage("testMsg");
>         sender.send(msg);
>     }
> }
> If "sender" is initialized in the initBean(), then a transaction does not propagate down into the sender.send().  If "sender" is initialized in the sendMessage() method, than a transaction is available.  
> Also note that I moved:
> @TransactionAttribute(TransactionAttributeType.REQUIRED)
> to the class level and the problem persisted.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list