zoukankan      html  css  js  c++  java
  • activiti 报 next dbid

    记录一下吧。

    今天将生产环境的几个服务节点改成集群模式,其中包含activiti审批服务节点,其中各个服务几点间数据通信采用MQ(与本文无关)。

    然后报出如题错误。

    究其原因就是,在启动activiti自动审批工作流的时候,activiti会查询act_ge_property表中的值来标识唯一工作流。单机情况下不会出现此状况,集群情况下才会出现该表锁异常的情况,所以报出了此错误。

    解决方法,就是在activiti配置文件中不让activiti在启动工作流的时候查询这张表,即采用主键注入策略,具体实行方法非常简单。

    1、需在项目中引入java-uuid-generator-3.1.2.jar包。有了此包才能生成UUID。

    2、在activiti配置文件中加入

    <property name="idGenerator"><bean class="org.activiti.engine.impl.persistence.StrongUuidGenerator" /></property>
    

    至于为什么要引入这个包,是因为:

    package org.activiti.engine.impl.persistence;
    
    import org.activiti.engine.impl.cfg.IdGenerator;
    
    import com.fasterxml.uuid.EthernetAddress;
    import com.fasterxml.uuid.Generators;
    import com.fasterxml.uuid.impl.TimeBasedGenerator;
    
    /**
     * {@link IdGenerator} implementation based on the current time and the ethernet
     * address of the machine it is running on.
     * 
     * @author Daniel Meyer
     */
    public class StrongUuidGenerator implements IdGenerator {
    
      // different ProcessEngines on the same classloader share one generator.
      protected static TimeBasedGenerator timeBasedGenerator;
    
      public StrongUuidGenerator() {
        ensureGeneratorInitialized();
      }
    
      protected void ensureGeneratorInitialized() {
        if (timeBasedGenerator == null) {
          synchronized (StrongUuidGenerator.class) {
            if (timeBasedGenerator == null) {
              timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
            }
          }
        }
      }
    
      public String getNextId() {
        return timeBasedGenerator.generate().toString();
      }
    
    }
    

    就OK了。

    这样就可以采用主键注入策略,而不使用activiti表中的值。也就不会再报出这个错误。

    参考文章链接地址:http://blog.csdn.net/kongqz/article/details/8027295

  • 相关阅读:
    MovieLens
    牛顿法与拟牛顿法学习笔记(一)牛顿法
    Softmax回归
    PCA练习
    PCA主成分分析
    算法——A*——HDOJ:1813
    spring 入门篇
    java——多线程——单例模式的static方法和非static方法是否是线程安全的?
    java——数据库——commons-DbUtils
    java——HashCode和equal方法
  • 原文地址:https://www.cnblogs.com/yidiandhappy/p/6674495.html
Copyright © 2011-2022 走看看