package com.bonus.mq.tx;

import com.bonus.mq.MQTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.SQLException;

public abstract class TxHolder {
   private static final Logger log = LoggerFactory.getLogger(TxHolder.class);
   private MQTemplate mqTemplate;

   public void end() {
      try {
         this.mqTemplate.txEnd(this);
      } catch (Throwable var2) {
         log.error("Commit transaction message failed, transaction state will be checked later", var2);
      }

   }

   public void commit() {
      this.mqTemplate.txCommit(this);
   }

   public void rollback(Throwable exception) throws SQLException {
      this.mqTemplate.txRollback(this, exception);
   }

   public void rollback() throws SQLException {
      this.rollback((Throwable)null);
   }

   public void unknown(Throwable exception) {
      this.mqTemplate.txUnknown(this, exception);
   }

   public void unknown() {
      this.unknown((Throwable)null);
   }

   public MQTemplate getMqTemplate() {
      return this.mqTemplate;
   }

   public void setMqTemplate(final MQTemplate mqTemplate) {
      this.mqTemplate = mqTemplate;
   }

   public TxHolder(final MQTemplate mqTemplate) {
      this.mqTemplate = mqTemplate;
   }
}
