Re: deadlock on com.swiftmq.tools.concurrent.Semaphore?
You wrote you see this behavior with large transactions only. Messages sent within an XA transaction are internally stored at the client-side XA session (which is bound to a XAResource) and transferred to the router when XAResource.end is called which disassociates the XAResource from the current Xid. If you send many messages within a XA transaction, this XA-end-request can become quite large. If you use the default network buffer sizes, the extension of the client output and router input buffers requires much time with the default 64 KB extends. This can lead to a request timeout.
What you see in the stack trace is a request timeout on XA-end in the upper stack and a normal wait for completion of XA-end in the stack below. There is no deadlock. The Semaphore is used to get asynchronously notified when a router-side operation is completed.
However, it would be wrong if the XA-end was called on the same XAResource. I can't see that because the upper call has the timeout.
Another possibility is that the request timeout was caused by an OutOfMemory (due to the large tx) at the router side. In that case a thread dies and a reply isn't send which leads to a request timeout on the client side.
Can you check the router logs for an OOM?
Are you able to reproduce the behavior with a single XA tx?