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

转载于:https://www.cnblogs.com/yidiandhappy/p/6674495.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值