Hi, can i have some suggestion regarding the design for the flow, in my case i have some sort of resource, lets say a single and only apple, and i have a process definition in order to buy it, since i allow to create multiple instances of orders to buy the apple, however i have only one apple, at some point, first process instance to reach the end, will consume the apple, and so other process instances must be terminated, can you please suggest if i should use Signal events or rather sending messages and how ?
Is the Apple only consumed at the very end of the process?
To simplify things let’s say it is consumed at the end of the process.
You could have a event sub process that listens for a message for signal and has a interrupting start event. And have easy step in your main process be async so it’s not all one transaction.
Can multiple processes instances be active at the same time, all trying to consume the same Apple? Or could only 1 instance be active at once?
Let me provide you a more detailed explanation
There is a process definition , let’s call it process definition 1, which contains some business flow between buyer end seller , and by the end of that flow, an apple will be sold to buyer. Now in case if have 2 instances actively running to sell apple1(process instance 1 and process instance 2), and 3 process instances to sell apple2(process instance 3,4,5), if let’s say process instance 2 reaches the sale, process instance 1 has to be terminated. Same goes for process instances to sell apple2, if one of them reaches the sale , the other two must be terminated.
You could wrap the tasks In a sub process and after each task (or whenever you feel it should be done) you check if the product has been sold/no longer available. And if it is no longer available you throw a BPMN error and catch it to process it. Something like: https://docs.camunda.org/manual/7.8/reference/bpmn20/events/error-events/#error-boundary-event
You could also look at using compensation events and tasks as there might be the need to roll back previous applied changes?
Are you trying to build a purchase flow / checkout flow?
Error handling will not cut it, because it will require you reaching resource allocation stage in order to find out that resource is no longer for sale, I’m trying to build sale negotiation flow, where seller might have multiple parallel negotiation instances but whichever flow reaches agreement first gets the resource and all other negotiations should be cancelled since there is nothing to negotiate for.
Thank you for suggestion, but I was considering pool with two lanes, for seller and buyer (should I switch to to two pools instead ?), can I still make boundary catch message event for entire pool? And how do I proceed to termination of the entire pool after receiving the message ?
Lanes are purely a Annotation/visual. They do not have any execution function in the engine.
What is the value you see in having two pools (which would mean two processes definitions)?
And how do I proceed to termination of the entire pool after receiving the message ?
Take a look at the docs on Sub-Processes and Message Boundary Events up on how Interrupting Message Events work. When the message is executed, the inner pool will not continue, and when the parent pool reaches the end event it will stop the process. THe Termination event is only used as a example of a “hard stop”, but in my scenario above a non end event would work as well.
I was considering two pools based on the example of two approval process except that buyer end seller are now negotiating with each other, constantly sending messages back and forth. After each party would receive certain message they would react upon then until one of the following week happen , either both would agree/ disagree and process will end or process will need to be terminated since other concurrent negotiation reached agreement for the same resource. I am having a hard time sorting out how to build this kind of interaction between two parties using subprocess and I would be very grateful if you would help me, thank you.
Is this a fixed list of steps they negotiate?
can you provide a flow diagram just written in Visio / not a BPMN, just a visual picture of how you envision it working
Stephan, thank you so much, I did not expect to have so many inputs from my first pits on form , right now it is 11 pm my region, and I cannot reach my PC, I will attach flow the rest thing tomorrow morning, however I can tell you flow seems to be fairly straightforward, buyer initiates flow buy filling out order request, afterwards seller has to review it, having 3 options , decline end the process ends, agree, end the process ends, end negotiation, if he chooses to negotiate, he has to provide negotiable item. After providing the negotiable item , the order is now moved back to buyer to review it, having same 3 options and so on.
Okay so what’s wrong if you build that flow? Looks reasonable.
in my flow, im not really sure how to send signal or message to terminate concurring flows after reaching the end, when in your diagram it is pretty straight forward, since the flow is encapsulated in subprocesss with boundary catch event to interrupt it.
There are no signals or messages in your design. And you have no parallel flows
considering that you might have multiple process instances, and only one item to sell, as soon as one of them to reach the end,it will have resource consumed, while other process instances will be continuing the negotiation for the sold item, and i want to interrupt that, but i dont know how.