[jboss-jira] [JBoss JIRA] (AS7-5625) Transaction propagation to a JMS QueueSender not occuring for CMT
jaikiran pai (JIRA)
jira-events at lists.jboss.org
Tue Sep 25 05:41:34 EDT 2012
[ https://issues.jboss.org/browse/AS7-5625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12721321#comment-12721321 ]
jaikiran pai commented on AS7-5625:
-----------------------------------
{quote}
If "sender" is initialized in the initBean(), then a transaction does not propagate down into the sender.send().
{quote}
That's because there's no transaction associated at that point. This is @Stateless bean and as per the spec, the @PostConstruct method of that bean doesn't run in a transaction context:
{quote}
EJB 3.1 spec, Section 4.3.4
The PostConstruct lifecycle callback interceptor methods for stateless and stateful session beans execute in an unspecified transaction context.
{quote}
> 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