<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Which HA-JMS ConnectionFactory?
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/gturner">Gerald Turner</a> in <i>JNDI and Naming</i> - <a href="http://community.jboss.org/message/572560#572560">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>How should I code transacted HA-JMS sender and receiver non-EJB clients deployed within a cluster of JBoss containers?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The question is tricky because: we're using JBoss 4.2.3 in "all" configuration, but would like to upgrade to 5.1 without code changes; the clients are SAR deployments of custom MBeans; no EJB/MDB whatsoever.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Various informal documentation I've been able to scrape from the web suggests looking up the ConnectionFactory from local (non-HA) JNDI with name "java:/JmsXA" and looking up the Queue from HA-JNDI.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>JmsXA is not working because evidently (and as it's name suggests) it is an XAConnectionFactory, and the code:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>QueueSession session =<br/>&#160;&#160;&#160; connection.createQueueSession(true, Session.SESSION_TRANSACTED);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#8230;is not actually honoring the transcted/mode arguments (javadoc: "usage undefined"&#185;).&#160; This becomes a problem when the receiver code issues session.commit() or session.rollback() which raise the exception "TransactionInProgressException: Should not be call from a XASession".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've searched for examples of using XASession from a non-EJB client and haven't come up with anything.&#160; I suppose I could try experimenting with session.getXAResource&#178;, but first problem faced would be how to allocate Xid objects, and then I imagine there will be failures because the underlying DataSource isn't XA (MySQL Cluster/NDB storage engine doesn't support XA).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Avoiding the XA mess and trying ConnectionFactory lookup with JNDI name "java:/ConnectionFactory" isn't working either: this object only exists on the master nodes local JNDI, it's not exported to HA-JNDI.&#160; I suppose I'll have to do remote JNDI connection to the master node?&#160; That sounds awful since I'll also need to detect and reconnect on master node failover.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Does JBoss 5.1 / JBoss Messaging "fix" any of this?&#160; I could change targets but I'm having massive interoperability problems between 4.2 and 5.1 in other applications (several clusters with total of 300+ JBoss application servers, "fork-lift" upgrade of our applications isn't<br/>pretty).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Any advice would be much appreciated!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span>&#185; </span><a class="jive-link-external-small" href="http://download.oracle.com/javaee/5/api/javax/jms/XAConnection.html#createSession(boolean,%20int" target="_blank">http://download.oracle.com/javaee/5/api/javax/jms/XAConnection.html#createSession(boolean,%20int</a><span>)</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span>&#178; </span><a class="jive-link-external-small" href="http://download.oracle.com/javaee/5/api/javax/jms/XASession.html#getXAResource" target="_blank">http://download.oracle.com/javaee/5/api/javax/jms/XASession.html#getXAResource</a><span>()</span></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/572560#572560">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JNDI and Naming at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>