Xafari Server. Operation Modes
There are 2 modes of the Xafari Server:
- Local (embedded) server
- Dedicated server
To determine the server mode, specify the UseDedicatedXafariServer key in appSettings section of the application config-file:
False - local XafariServer is used;
True - dedicated XafariServer is used.
<add key="UseDedicatedXafariServer" value="False" />
False value specifies the operation in local mode. Messages are processed in separate threads within the process of the client application. In this case, the Message Queue is in memory of the application, not in the database. Queue is individual for each application instance. After completing the application, all messages from the queue are lost. This mode can be used to perform non-critical tasks in the background.
Dedicated server mode means that the client side of the application does not handle the Message. The client side of the application only adds Messages to the Queue. The Message Queue is stored in the database. The Message Queue is shared by all application instances. The Messages from the Queue performs a separate Xafari Server. Waiting for the result of processing, the client application can periodically check the status of Messages. All modules needed by the message handlers must be connected to the server application. Generally, all modules of the client side of the application and modules containing message handlers should be specified in the server application.
To implement the server part, Xafari Framework provides the use of command-line RunCmd.exe utilitie with the StartXafariServer command.
Xafari Framework provides the use of command-line RunCmd.exe utilitie with the StartXafariServer command as a server. This command is implemented in the Xafari.Server.dll module. To use RunCmd.exe as a dedicated server, follow the steps described below.
Configure the application:
- Add AppModule to the Modules key of the application config-file. It is also required to load Xafari.Server module, and the modules containing message handlers. There are several ways to achieve this. You can list the modules in the Modules key (modules separated by a semicolon), and you can download them using AppModule.
- Set ValueManager key to the "Xafari.XafariMultiThreadValueManager`1" value.
- Set UseDedicatedXafariServer key to the "True" value.
Northwind.DC demo instaled with Xafari generates reports using Xafari Server, message handler is implemented in the Xafari.Reports.Server module. The snippet bellow demonstrates configuration options for this application:
<add key="ValueManagerType" value="Xafari.XafariMultiThreadValueManager`1" />
<add key="Modules" value="Xafari.Northwind.DC.AppModule;Xafari.Reports.Server" />
<add key="UseDedicatedXafariServer" value="True" />
Copy to a separate directory all the files required for client side of the application (assemblies, *.xafml files, config-file etc.)
Start the server by typing one-line command in console:
RunCmd.exe /appconfig Xafari.Northwind.DC.Win.App.exe.config /l AuthenticationType:ActiveDirectory /c StartXafariServer
The command above is for the Northwind.DC.Win demo application. Command specifies the config-file and the authentication parameters (). Northwind.DC is authenticated using the class XafariAuthenticationLogonParameters. The /l key specifies the property values of this class when you run the console client. StartXafariServer command implements Xafari Server in console mode. With the successful start of the server, the following console message will appear:
"Starting Xafari Server... ok
Xafari Server is running... (press Ctrl+C or Ctrl+Break to stop)."
To learn more about RunCmd.exe, refer to the Console Application section.