that sounds like a reasonable optimization that can avoid the need to create a connection if the RA is deployed in local transaction only mode (ie: uses the regular non xa connection factory) One thought, it may be a good idea to produce a simple junit test case that demonstrates the timing issue with connection creation and immediate close, this may be a more general problem.
On 28 December 2010 02:29, Ivan <xhh...@gmail.com> wrote: > Hi, > I am learning the ActiveMQ RA module, and could not understand some > codes in the getXAResources method of ActiveMQResourceAdapter class, please > help to give some comments, thanks. > a. The implementation class of XAResource is > org.apache.activemq.TransactionContext, and it holds a reference to a > ActiveMQConnection, so is it reasonable to close the connection in the > finally block ? > b. Sometimes, while calling the connection.close() method, the > wireformat handshaking is not finished, and some EOFException or Socket > reset exception is always thrown, although it might not cause problems, it > seems to be annoying. So if the XaSession is only created by > ActiveMQXAConnection, and ActiveMQXAConnection could only be created by > ActiveMQXAConnectionFactory, so how about checking whether the connection > factory is an instance of XAConnectionFactory. > If I do not miss anything, I could try to open a JIRA and create a > patch. > > ---> > public XAResource[] getXAResources(ActivationSpec[] activationSpecs) > throws ResourceException { > Connection connection = null; > try { > connection = makeConnection(); > if (connection instanceof XAConnection) { > XASession session = > ((XAConnection)connection).createXASession(); > XAResource xaResource = session.getXAResource(); > return new XAResource[] { > xaResource > }; > } > return new XAResource[] {}; > } catch (JMSException e) { > throw new ResourceException(e); > } finally { > try { > connection.close(); > } catch (Throwable ignore) { > // > } > } > } > <---- > > -- > Ivan > -- http://blog.garytully.com http://fusesource.com