/**PageBeginHtml Block Begin **/ /***自定义返回顶部小火箭***/ /*生成博客目录的JS 开始*/ /*生成博客目录的JS 结束*/

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

posted @ 2020-12-05 19:15  一品堂.技术学习笔记  阅读(417)  评论(0编辑  收藏  举报