Run parts of after start-up microflow only on 1 instance

0
Is it possible to run parts of the start-up microflow only on 1 instance? I know the CF_INSTANCE_INDEX environment var is 0 for the leader (used for scheduled event execution). Can we access that variable from the JVM or does the JVM policy deny access?
asked
4 answers
0

Menno,

From the documentation on clustered instances found here: https://docs.mendix.com/refguide/clustered-mendix-runtime

this does not seem possible.

answered
0

Hi Erwin,

Thanks for your reply. I think it is not officially supported by Mendix. The runtime knows on which node to execute scheduled event. So the instance type (master or slave) should be stored/set somewhere; both on OS and Runtime level.

answered
0

I tested the following on the Mendix Cloud and works as expected.

Create a Java action with the following code:

Long.valueOf(System.getenv("CF_INSTANCE_INDEX"));

This will return 0 for the Leader node and larger than 0 for the Slave nodes. Strange the JVM policy permits it, because if you emulate Cloud security locally, it will inject the following policy that prevents it for executing:

permission java.lang.RuntimePermission "getenv.CF_INSTANCE_INDEX";

Do not forget to catch exceptions properly, because if you run the application locally, it will not be able to read and parse the CF_INSTANCE_INDEX environment variable.

answered
0

Is it useful to create a module for the community?!

answered