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.
The client creates a session with common data, sends 10 input messages with "Hello Grid!!" through Symphony to the service and retrieves the output synchronously.
The service accesses the common data in onSessionEnter() and stores it in the service container to be accessed during each task invocation. The service then takes input data sent by the client and returns the input data along with "Hello Client !!".
Use common data when the same data is shared among all tasks in a session. You only need to store the data once, and all tasks in a session can access it.
Common data is useful for passing data from a client to a service. The service loads the data when the session is created.
Symphony attempts to use the same service instance for all tasks in a session. A service instance is made available to other sessions only when session workload completes, a session is closed or aborted, or when another session of higher priority is assigned the service instance.
In this tutorial, different classes represent input and output. In addition, we are using an additional class to represent common data.
As in the synchronous client tutorial, initialize the client and connect to the application. Then, create your session to group tasks.
When creating a session, use the common data object to pass data from the client application to the service.
In SharingDataClient.java, we create a session and pass in the session attributes including the common data object.
As in the basic service tutorial, first define a service container. Then retrieve the common data from the session sent by the client by implementing onSessionEnter() before your invoke call.
onSessionEnter() is called once for the duration of the session. The corresponding pair is onSessionLeave().
In SharingDataService.java, we inherited from the ServiceContainer class, and implemented onSessionEnter() to get common data and store it for later use with the session context.
In this example, we use the common data in our invoke call by formatting the output string. We then set our output message as usual to send common data back with each of the replies.
After processing the input, use the onSessionLeave() call to free the data for the session. onSessionLeave() is called once for every session that is created. In this example, we do not perform any operations in onSessionLeave().
As with the basic service, run the container in the service main and catch exceptions.