My flows are configured in the database and my program continuously creates and destroys the flows.
So the flow configurations (for example the cron configuration) can be any time changed.
The flows are registered with the method IntegrationFlowContext.register
and destroyed with the method IntegrationFlowRegistration.destroy
.
The running of the flows starts at second 0 and can be at any minute. The destroying and creating the new flows starts every minute at second 1.
Is this a good approach? When I tested this, it works. But I'm thinking, is this a good way to do this, because some flow can be running same time when it is destroyed.
The pseudocode is for example
-at 13pm 00 minutes 00 seconds
-run the flow for the customer X
-at 13pm 00 minutes 01 seconds
-destroy all the flows (including the customer flow X)
-register all the flows (including the customer flow X)
-at 13pm 01 minutes 01 seconds
-destroy all the flows (including the customer flow X)
-register all the flows (including the customer flow X)
-at 13pm 02 minutes 01 seconds
-destroy all the flows (including the customer flow X)
-register all the flows (including the customer flow X)
...
-at 13pm 59 minutes 01 seconds
-destroy all the flows (including the customer flow X)
-register all the flows (including the customer flow X)
-at 14pm 00 minutes 00 seconds
-run the flow for the customer Y
-at 14pm 00 minutes 01 seconds
-destroy all the flows (including the customer flow Y)
-register all the flows (including the customer flow Y)
Edit:
This is needed, because I don't want to restart the server if the configuration in the database changes. I'm thinking is this a good approach or should I change this.
Edit 2:
I can simplify my question. Is there any problem if some flow is deleted with the method IntegrationFlowRegistration.destroy
when it is running?
Edit 3:
I have found that the flow can't be deleted with the method IntegrationFlowRegistration.destroy
when it is running. If there are multiple flows running same time then some flows are not run to the end.
Is there any way to detect if some flow is running? I looked the IntegrationFlowRegistration
class and some other classes, but I didn't find the appropriate method.
I did this so that I only stop and destroy those flows which are changed in the database. So I don't destroy those flows which are not changed. So it's unlikely that the running flow is deleted.