工作取消在多实例 Activiti 6 设置中

huangapple go评论61阅读模式
英文:

Job cancellation in multi instance Activiti 6 setup

问题

我有一个服务,它会启动一个Activiti实例,并帮助进行作业管理。为了满足可扩展性的需求,我计划启动多个该服务的实例。这意味着会有多个Activiti 6引擎实例,在一个负载均衡器后面。所有这些实例都会连接到同一个数据库。

在单实例设置中,作业取消运行得非常好。然而,在拥有多个Activiti实例的情况下,取消操作并不总是可靠。更具体地解释,如果Activiti实例#1已经启动了作业#1和#2,而实例#2已经启动了#3和#4。如果将取消作业#1的请求发送到Activiti#1,那么一切都会正常工作,但如果该请求发送到#2,则作业取消将无法正常工作。

让这一切正常运作的一种方法是将每个取消请求广播到每个Activiti实例。另一种方法是在外部记录与每个作业关联的实例。然而,这两种方法都不太优雅。

我的问题是,如何处理这种情况的最佳实践是什么?是否有任何推荐的模式可以遵循?

提前致谢。

英文:

I have a service which brings up an Activiti instance along with it and helps with job management. For scalability needs, I plan to spin off multiple instances of this service. This would mean multiple instances of Activit 6 engine, behind a load balancer. All of these end up connecting with the same DB.

Job cancellation works perfectly fine in a single instance setup. However, cancellation does not work reliably when I have multiple instances of Activiti. To explain further, if Activiti instance #1 had started job #1 and #2, while instance #2 had started #3 and #4. A cancel request for job #1 if sent to Activiti #1 would work fine, but if that request goes to #2, job cancellation does not work.

One way for me to make this work is broadcast every cancel request to every Activiti instance. The other would be for me to externally book-keep the instance associated with every job. Both of these do not look clean.

My question - what is the best practice around handling such scenarios? Are there any recommended patterns that can be followed?

Thanks in advance.

答案1

得分: 1

显然,对于单个引擎实例,正确的方法是使用信号或消息事件处理程序,但是正如您所说,这在多个引擎实例的情况下不起作用。
广播选项可能是最简单的方法,如果实例不在流程的某个有意义的部分,它将被简单地忽略。
更清晰但更复杂的解决方案是将此处理外部化为应用程序表,甚至可以是文件系统上的一个简单文件。实例将寻找“标志”并退出,但您需要确保在最后一个实例退出时清除该标志。
无论如何,我无法想到引擎本身内部会提供您所需内容的任何方法。

英文:

Obviously the right answer here for a single engine instance is to use a signal or message event handler, however this doesn't work for multiple engine instances as you say.
The broadcast option is probably the simplest, if the instance isnt in a part of the process where the message is meaningful it will simply be ignored.
The cleaner, although more complex, solution is to externalize this handling into an application table or even something as simple as a file on the filesystem. Instances would look for the "flag" and exit, however you need to make sure the flag is cleared on exit of the last instance.
Either way, I can't think of anything inside the engine itself that would offer what you need.

huangapple
  • 本文由 发表于 2020年4月10日 02:03:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/61127418.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定