Getting Started with Connexis HelloWorld Model

Model RealTime contains a sample Connexis model which demonstrates the use of the Connexis Locator Service and how it can be used to provide a backup locator service in a distributed environment. Open the sample model by performing File – New – Example. Under the "UML Capsule Development" category, select the "Connexis_HelloWorldOverflowToBackupService" example.

Import the Connexis library model to your workspace (File – Import – General – Existing Projects into Workspace). The project to import is located in the Model RealTime installation under rsa_rt/Connexis/DCS.

The Connexis HelloWorld sample model contains two servers, a client, and the Connexis Locator service, each running as independent applications. The servers speak different languages (either English or French). Initially, a client is bound to the server that comes up first. Once bound, the client makes periodic requests to the server and the server sends back a greeting in the language it speaks.

If the server to which the client is bound becomes unavailable, the client is notified of the connection loss. It then rebinds to the backup server, which starts responding to the client requests in the language it speaks. For example, if the client is initially bound to the English server, it will start receiving greetings in English. If you then terminate the English server, the connection will be lost momentarily. The client will then be rebound to the French server, and after a short while the client will start receiving the greetings in French instead.

Another thing demonstrated by this sample is overflow handling. The English server is given a higher rank so that it acts as the primary server. The clients connect to the primary server until the primary server has reached its full capacity (2 clients in the example). Any subsequent client that is launched will be connected to the French backup server instead.

Building and Running the HelloWorld Model

Build the four executables using the TCs that are located in a folder named after your platform. For example, for MinGW the folder is called "TCs-win64-MinGW". Note that the TCs for different platforms have the same names (it’s only the folder name that is different). It is therefore recommended to have the "Transformation Configuration Files" filter in the Project Explorer turned off so you can see the *.tcjs files under the folders and not just under the Transformation Configuration virtual folder.

Go to the target folder for each TC and start the generated application: Start the locator application first:

Locator.EXE -CNXep=10000 -CNXlp -CNXui=PrimaryLocator
-CNXlbep=cdm://localhost:10001 -URTS_DEBUG=quit

Then start the English server:

EnglishServer.EXE -CNXep=10020 -CNXui=EnglishServer -CNXlpep=cdm://localhost:10000 -CNXlbep=cdm://localhost:10001 -URTS_DEBUG=quit

And, finally start the French server:

FrenchServer.EXE -CNXep=10030 -CNXui=FrenchServer -CNXlpep=cdm://localhost:10000 -CNXlbep=cdm://localhost:10001 -URTS_DEBUG=quit

Now start four independent clients, making sure to give each one a unique name and port:

Client.EXE -CNXep=10010 -CNXui=Client1 -CNXlpep=cdm://localhost:10000 -CNXlbep=cdm://localhost:10001 -URTS_DEBUG=quit

Client.EXE -CNXep=10011 -CNXui=Client2 -CNXlpep=cdm://localhost:10000 -CNXlbep=cdm://localhost:10001 -URTS_DEBUG=quit

Client.EXE -CNXep=10012 -CNXui=Client3 -CNXlpep=cdm://localhost:10000 -CNXlbep=cdm://localhost:10001 -URTS_DEBUG=quit

Client.EXE -CNXep=10013 -CNXui=Client4 -CNXlpep=cdm://localhost:10000 -CNXlbep=cdm://localhost:10001 -URTS_DEBUG=quit

You should see that client 1 and 2 start to print "Hello World!!!" since they were connected to the English server, while client 3 and 4 print "Salut le monde!!!" since they were connected to the French server (because the specified capacity of the English server only allows two connected clients).

You should also see that if you terminate the English server, client 1 and 2 after a while get reconnected to the French server and therefore start to print the message in French instead.


Watch the demo video for getting started with HelloWorld using Connexis library:

A "HelloWorld" demo of Connexis