Project Running Sequence (Magic xpi 4.14)
The following steps describe the sequence of events that occur when your projects status is RUNNING.
-
When the project is running, three elements operate simultaneously: workers, polling triggers, and external triggers. Each Magic xpi server can run one or more workers/triggers for a variety of tasks:
-
A polling trigger (such as the Directory Scanner), also known as an asynchronous trigger, is a Magic xpi server thread that constantly checks external systems (such as an email account) to see whether it needs to invoke a flow without waiting for a response. When it needs to invoke a flow, it places a flow message with a status of READY_FOR_USE in the IMM .
-
Each available worker scans the IMM for jobs to execute, meaning messages whose status is READY_FOR_USE. When the worker finds a message, it changes the status to IN_PROCESS, passes the message payload to the flow, and executes the flow logic. (This is known as a pull mechanism.)

|
To prevent two workers from executing the same message, the change of the status to IN_PROCESS is performed in a transaction so that only one worker will succeed.
|
-
An external trigger, such as the HTTP Requester or a Web server, is an external application. Once the trigger receives a request, it places a message in the IMM that invokes the flow. The synchronous external triggers will also wait for a response message.
-
When the main flow is completed, the worker updates the request message’s status in the IMM to DONE, and is then free to scan for additional messages.
-
If the message is from a synchronic trigger (such as an HTTP trigger), when the flow ends, the worker writes a response message to the IMM , which the trigger will send to the client.
-
Every parallel and stand-alone branch is also handled as a separate message written by the flow to the IMM . This new thread (the parallel or stand-alone branch) can be handled by any of the project's workers, even a worker running on a different machine.

|
For a visual explanation of how the server architecture works, click here.
|