users@genericjmsra.java.net

XAQueueConnectionFactory

From: matthias.fraass_at_tricoder.net <matthias.fraass_at_gmail.com>
Date: Mon, 4 Jan 2010 15:27:59 +0100

Hi,

we connected Glassfish to Sonic via genericra.
It works fine so far for standard purposes.

But we need access to the XAResource (BMT, enlisting it within a
distributed connection).

But com.sun.genericra.outbound.ConnectionFactory does only implement
QueueConnectionFactory, not XAQueueConnectionFactory. Is there a
reason for this?

I tried a quick hack and extended this class by implementing
XAQueueConnectionFactory like this

@Override
public XAQueueConnection createXAQueueConnection() throws JMSException {
        return ((XAQueueConnection)createXAConnection());
    }

@Override
public XAQueueConnection createXAQueueConnection(String userName,
                String password) throws JMSException {
        return ((XAQueueConnection)createXAConnection(userName, password));
}

@Override
public XAConnection createXAConnection() throws JMSException {
        XAConnection con = null;
    try
    {
      con = (XAConnection)this.cm.allocateConnection(this.mcf, null);
    } catch (ResourceException e) {
      logger.log(Level.INFO, e.getMessage(), e);

      throw ExceptionUtils.newJMSException(e);
    }

    return con;
}

@Override
public XAConnection createXAConnection(String userName, String password)
                throws JMSException {
    ConnectionRequestInfo info = new ConnectionRequestInfo(this.mcf,
userName, password);

    XAConnection con = null;
    try
    {
      con = (XAConnection)this.cm.allocateConnection(this.mcf, info);
    } catch (ResourceException e) {
      logger.log(Level.INFO, e.getMessage(), e);

      throw ExceptionUtils.newJMSException(e);
    }

    return con;
}

I also had to extend ConnectionHandle accordingly (implement
XAConnection, XAQueueConnection).
It seems to work fine:

        @Resource(mappedName = "someXACF")
        private XAQueueConnectionFactory sonicConnectionFactory;
...
        XASession session =
sonicConnectionFactory.createXAConnection().createXASession();
        XAResource res = session.getXAResource();
...

Could you add these enhancements as well?

Best regards,

Matthias