Tabnine Logo
TxTransactionLocal
Code IndexAdd Tabnine to your IDE (free)

How to use
TxTransactionLocal
in
org.dromara.raincat.core.concurrent.threadlocal

Best Java code snippets using org.dromara.raincat.core.concurrent.threadlocal.TxTransactionLocal (Showing top 7 results out of 315)

origin: yu199195/Raincat

@Override
public void apply(final RequestTemplate requestTemplate) {
  requestTemplate.header(CommonConstant.TX_TRANSACTION_GROUP, TxTransactionLocal.getInstance().getTxGroupId());
}
origin: yu199195/Raincat

  /**
   * 补偿的时候,不走分布式事务处理.
   *
   * @param point point 切点
   * @param info  信息
   * @return Object
   * @throws Throwable ex
   */
  @Override
  public Object handler(final ProceedingJoinPoint point, final TxTransactionInfo info) throws Throwable {
    TxTransactionLocal.getInstance().setTxGroupId(CommonConstant.COMPENSATE_ID);

    PlatformTransactionManager platformTransactionManager =
        TransactionManagerHelper.getTransactionManager(info.getTransactionManager());
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    TransactionStatus transactionStatus = platformTransactionManager.getTransaction(def);
    try {
      final Object proceed = point.proceed();
      platformTransactionManager.commit(transactionStatus);
      return proceed;
    } catch (Throwable e) {
      platformTransactionManager.rollback(transactionStatus);
      throw e;
    } finally {
      TxTransactionLocal.getInstance().removeTxGroupId();
      CompensationLocal.getInstance().removeCompensationId();
    }
  }
}
origin: yu199195/Raincat

final String taskKey = IdWorkerUtils.getInstance().createTaskKey();
final BlockTask task = BlockTaskHelper.getInstance().getTask(taskKey);
TxTransactionLocal.getInstance().setTxGroupId(info.getTxGroupId());
txTransactionThreadPool
    .newFixedThreadPool()
    .execute(() -> {
      TxTransactionLocal.getInstance().setTxGroupId(info.getTxGroupId());
      final String waitKey = IdWorkerUtils.getInstance().createTaskKey();
origin: yu199195/Raincat

TxTransactionLocal.getInstance().setTxGroupId(groupId);
    throw throwable;
  } finally {
    TxTransactionLocal.getInstance().removeTxGroupId();
origin: yu199195/Raincat

  @Override
  public Response filter(final Caller<?> caller, final Request request) {
    request.setAttachment(CommonConstant.TX_TRANSACTION_GROUP, TxTransactionLocal.getInstance().getTxGroupId());
    return caller.call(request);
  }
}
origin: yu199195/Raincat

  @Override
  public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, final ClientHttpRequestExecution execution) throws IOException {
    request.getHeaders().add(CommonConstant.TX_TRANSACTION_GROUP, TxTransactionLocal.getInstance().getTxGroupId());
    return execution.execute(request, body);
  }
}
origin: yu199195/Raincat

  @Override
  public Result invoke(final Invoker<?> invoker, final Invocation invocation) throws RpcException {
    if (RpcContext.getContext().isConsumerSide()) {
      RpcContext.getContext().setAttachment(CommonConstant.TX_TRANSACTION_GROUP,
          TxTransactionLocal.getInstance().getTxGroupId());
    }
    return invoker.invoke(invocation);
  }
}
org.dromara.raincat.core.concurrent.threadlocalTxTransactionLocal

Javadoc

TxTransactionLocal.

Most used methods

  • getInstance
  • getTxGroupId
  • removeTxGroupId
  • setTxGroupId

Popular in Java

  • Making http requests using okhttp
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getApplicationContext (Context)
  • getSystemService (Context)
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • JFrame (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now