Currently, the code loops and retries the begin_transaction operation, but it makes more sense to simply throw a WCE and let its retry loop do the work.