• activiti 报 next dbid




    activiti 报 next dbid

    记录一下吧。

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

    然后报出如题错误。

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

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

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

    2、在activiti配置文件中加入

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


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

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    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

  • 相关阅读:
    数据库之完整性约束
    数据库之数据类型
    数据库之表操作,数据操作
    mysql数据库之基本操作和存储引擎
    MySQL数据库之安装
    并发编程之socketserver模块
    python并发编程之IO模型
    [BZOJ 3207] 花神的嘲讽计划Ⅰ【Hash + 可持久化线段树】
    [BZOJ 1046] [HAOI2007] 上升序列 【DP】
    [BZOJ 1816] [Cqoi2010] 扑克牌 【二分答案】
  • 原文地址:https://www.cnblogs.com/ios9/p/14090719.html
Copyright © 2020-2023  润新知