Runtime tools : Channels components : Java Client/Server Messaging APIs : Tasks : Invoking a business process
  
Invoking a business process
To invoke a business process, the client operation gets a CSClient instance and calls the instance's sendAndWait method, passing itself as a parameter, as shown in the following example:
((CSClientService) CSClient.getCSClient("realCSClient")).sendAndWait(this,10000);
With the code above, the client operation sends a data buffer to the server side to invoke the appropriate business process. Because this is a synchronous request, the client operation waits 10 seconds (set in the method call) for the response. If the response does not arrive within the specified time, the client operation must handle the DSECSTimeoutException. Once the response arrives on the client, the Client/Server Mechanism unformats the incoming stream and updates the operation context.
For asynchronous requests, the client operation uses the send method of the CSClient instance as shown in the following example:
Integer requestID = ((CSClientService) CSClient.getCSClient("realCSClient")).send(this);
In this case, the client operation must register with the Client/Server Service as a listener for the CSReplyEvent. This enables the client operation to handle the response. It also means that the operation can have multiple requests happening at the same time. The client operation registers as a listener using code like the following example:
((CSClientService) CSClient.getCSClient("realCSClient")).receive(this,requestID,10000);
You can also configure Client/Server Mechanism to handle a timed out synchronous request by setting receiveReplyAfterSynchronousSendTimeout to true. The DSECSTimeoutException contains the ID of the request. When the Client/Server Mechanism receives the response from the application logic layer, if the parameter is true, the mechanism sends a CSReplyEvent. The client operation must register as a handler of this event. The operation can then retrieve the request ID from the event and use it when invoking receive method to retrieve the response.
Go up to
Tasks