我在 BillingCenter Guidewire 中创建了一个工作队列来处理大数据,但是对于某些记录,数据库返回异常“数据库 bean 版本冲突:”
有人可以帮助我吗?
控制工人如何处理记录没有冲突的进程?
问候, 道格拉斯·雷森德
当实体是可版本化的并且两个进程正在更改相同的“记录”时,就会发生该异常。我认为您需要为 WorkQueue 的 findTargets 方法添加一个控件,也许您的 WorkQueue 的一个新实例在最后一次执行完成之前正在运行。
private var _lock : ReentrantLock = new ReentrantLock()
private final static var _batchProcessType = BatchProcessType.TC_JOBEXPIRE
override function findTargets(): Iterator<PolicyPeriod> {
using( _lock ) {
var maintenanceToolsAPI = new gw.webservice.pc.pc800.MaintenanceToolsAPI()
if (!maintenanceToolsAPI?.getWQueueStatus(_batchProcessType.Code)?.NumActiveWorkItems != 0) {
// ...
}
return {}.iterator() as Iterator<PolicyPeriod>
}
}
这样可以验证不存在带有活动项目的一次执行。
If you distribute the load of your work queue across the cluster and you have messages changing the same entity this will happen. Guidewire 9 implements the concept of lease to get resources, you can implement a similar concept to avoid concurrency when sharing load of the work queue - keep a centralized table with records being processed (ID, Entity Type and status should be enough) and when you are finding records verify against that table that they are not being processed.