Does MySQL support querying for the current running transaction id
Starting with MySQL 5.7, you can see the current transactions in the performance schema.

See http://dev.mysql.com/doc/refman/5.7/en/events-transactions-current-table.html

Now, to find out the THREAD_ID of the current connection, use

SELECT THREAD_ID FROM performance_schema.threads
  WHERE PROCESSLIST_ID = CONNECTION_ID()


See http://dev.mysql.com/doc/refman/5.7/en/threads-table.html