Why did you choose to involve the connection in this, at all? A JMS transaction is always localized at session level.
I could see the reason JBossMQ does that: because only the connection has access to the ServerIL, which physically sends stuff to the server.
There is more to it that when JTA (transaction interleaving) is involved.
You can have one session do some work in the transaction, then it leaves
the transaction. Later another session takes over.
The jms session(s) maybe involved in a different transactions when the XAResource
commit lifecycle is invoked.
This is why there is the notion of transaction state is separate from the session.
I see. The connection delegate, or more precisely the ResourceManager's map acts as an aggregator for messages possibly coming from different sessions that joined the same transaction. This only applies to XASessions, though, but it's enough to justify the current design.