Project Running Sequence (Magic xpi 4.13)
The following diagram describes the sequence of events that occur when your project's status is RUNNING:
The Magic xpi servers (engines) communicate with the Magic Space through a GigaSpaces proxy (the middleware layer) that connects client applications to the Magic Space. The Magic Space can reside on a number of processes and a number of machines as a single unit. It is the responsibility of the GigaSpaces proxy to make the right connections between the servers and the Space partitions.
-
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 Magic Space.
-
Each available worker scans the Magic Space 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 Magic Space 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 Magic Space 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 Magic Space, 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 Magic Space. 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.
|