I’m working on a case consisting of multiple stages, each with several processes. In some processes, I’m sending out emails as part of the workflow. However, the very last email in a process often takes time to send, which slows down the overall user experience since the next task (in a new process/stage) cannot start until the previous process finishes.
What I’ve Tried:
Using async tasks for email sending, but this didn’t work as expected.
Using a Send Event Task, but the process still waits until the email is sent before proceeding.
Question:
Is there a recommended, clean way to separate email sending activities from the main process to improve performance and ensure the user can proceed with tasks without delays?
Any suggestions or best practices would be greatly appreciated!
Many thanks for the super-fast reply—really appreciated!
I actually tried implementing this approach using a parallel gateway, but I encountered an issue: the process still seems to wait at the very end for the email task to complete before finishing the process (20-30 seconds, partially because of internal checks on the emails). This behavior prevents the process from fully decoupling the email-sending activity and impacts the overall flow performance.
Any thoughts on how I can ensure the process finishes independently of the email task?
If you want to decouple that, then you need to use the events / channel mechanism. You send an event from one process, which is captured by an independent process that will do the mail sending.
I actually tried this approach with the following configuration:
Process A:
Configured an outbound event to trigger the email.
Mapped all parameters, including correlation IDs (e.g., caseId and processId).
Enabled the Flowable internal event bus (without specifying any external channels).
Process B:
Configured an inbound event to listen for the same event type and mapped all parameters.
No channels were selected, as I’m using the Flowable internal event bus.
However, I noticed that in the UI, the correlation IDs aren’t highlighted in the inbound event setup (unlike the CMMN model where they are clear).
Issues:
The process in Process A still seems to stop at the Send Event Task until the email is sent, which defeats the purpose of decoupling the email task from the main flow (also tried to make the Send Event Task Async, response took even longer).
The email is being sent 3 times, even though the outbound and inbound events are defined only once in each process. This is very strange.
You’re the best—thank you! It works perfectly now, and the process flows much smoother. I really appreciate your help!
I do have one follow-up question: now that the emails are sent asynchronously, is there a way to control the order of the emails? For example, if someone moves quickly through the process and multiple email triggers are sent in rapid succession, it could lead to confusion if emails arrive in the wrong order.
Is there a way to ensure that emails are sent in the correct sequence, even when they’re triggered asynchronously?
This is a bit more tricky, you might be able to do it with modeling, e.g. a single process for all the emails with receive events, but you need to be careful for the receive event to be created before the send.