Creating an authenticated XA resource from ActiveMQConnectionFactory
<p>I have an Apache ActiveMQ Artemis (1.3) instance to which I'm trying to connect from a standalone Spring (4.3.2) application my team is currently working on. It has Spring <em>JTATransactionManager</em> using Atomikos (4.0.4) <em>UserTransactionManager</em> as a provider and during those transactions I need to connect to several resources, including the aforementioned MQ. Following Artemis and Atomikos manuals we've set up <em>ActiveMQConnectionFactory</em> which then gets passed to <em>AtomikosConnectionFactoryBean</em>. It all happens in a Spring container but that doesn't seem to be related to our problem.</p>

<p>It all worked well until I tried to add authentication to the MQ connection. One can set <em>user</em> and <em>password</em> properties on an instance of <em>ActiveMQConnectionFactory</em>, however, they seem to be taken into account only when creating an ordinary connection:</p>

<pre><code>@Override
public Connection createConnection() throws JMSException {
  return createConnection(user, password);
}

@Override
public Connection createConnection(final String username, final String password) throws JMSException {
  return createConnectionInternal(username, password, false, ActiveMQConnection.TYPE_GENERIC_CONNECTION);
}
</code></pre>

<p>Atomikos is calling <em>createXAConnection</em>() method (from <em>XAConnectionFactory</em> interface) which, as I see in its implementation, disregards the credentials unless explicitly passed:</p>

<pre><code>@Override
public XAConnection createXAConnection() throws JMSException {
  return createXAConnection(null, null);
}

@Override
public XAConnection createXAConnection(final String username, final String password) throws JMSException {
  return (XAConnection) createConnectionInternal(username, password, true, ActiveMQConnection.TYPE_GENERIC_CONNECTION);
}
</code></pre>

<p>This is the way a few other methods in this class work as well, therefore I assume it's not a bug. If so, how should I obtain an authenticated <em>XAConnection</em>? I don't see the possibility of Atomikos calling the overloaded version, looking at its code.</p>

<p>Regards,
Jakub</p>