Could anyone help to give some comments ?
Thanks.

2010/12/28 Ivan <xhh...@gmail.com>

> 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
>



-- 
Ivan

Reply via email to