When you add an application through the DE PMC, you must use the Add Application wizard. This wizard defines a consumer location to associate with your application, deploys your service package, and registers your application. After completing the steps with the wizard, your application should be ready to use.
You review the sample client application code to learn how you can understand the differences between a synchronous client and an asynchronous client.
The client application sample sends 10 input messages with the data Hello Grid!! and retrieves the results.
Results are returned asynchronously with a callback interface provided by the client to the API. Methods on this interface are called from threads within the API when certain events occur. In the sample, the events are:
Because results can come back at any time, it is probable that your callback code needs synchronization between the callback thread and the controlling thread. The controlling thread needs to know when work is complete.
Results are not sent back in order. If order of results is important, the client application must sort the results.
Perform this step after declaring the Message object and implementing the MyMessage object.
In MyCallback.h, we create our own callback class from the SessionCallback class, and we implemented onResponse() to retrieve the output for each input message that we send.
onResponse() is called every time a task completes and output is returned to the client. The task output handle allows the client code to manipulate the output.
If there is output to retrieve, populateTaskOutput() gets the output. Once results return, we print them to standard output and return.
In AsyncClient.cpp, perform this step after you have connected to the application.
When creating an asynchronous session, you need to specify the session attributes by using the SessionCreationAttributes object. In this sample, we create a SessionCreationAttributes object called attributes and set four parameters in the object.
The first parameter is the session name. This is optional. The session name can be any descriptive name you want to assign to your session. It is for information purposes, such as in the command line interface.
The second parameter is the session type. The session type is optional. You can leave this parameter blank or not make the API call at all. When you do this, system default values are used for your session.
The third parameter is the session flag, which we specify as ReceiveAsync. You must specify it as shown. This indicates to Symphony that this is an asynchronous session.
The fourth parameter is the callback object.
We pass the attributes object to the createSession() method, which returns a pointer to the session.