Reputation: 562
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.
Upvotes: 0
Views: 103
Reputation: 3240
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.
Upvotes: 1