Professional Documents
Culture Documents
CoolGen-Asynchronous Processing Guide-GNASY600
CoolGen-Asynchronous Processing Guide-GNASY600
This documentation may not be copied, transferred, reproduced, disclosed or duplicated, in whole or in part,
without the prior written consent of CA. This documentation is proprietary information of CA and protected by the
copyright laws of the United States and international treaties.
Notwithstanding the foregoing, licensed users may print a reasonable number of copies of this documentation for
their own internal use, provided that all CA copyright notices and legends are affixed to each reproduced copy. Only
authorized employees, consultants, or agents of the user who are bound by the confidentiality provisions of the
license for the software are permitted to have access to such copies.
This right to print copies is limited to the period during which the license for the product remains in full force and
effect. Should the license terminate for any reason, it shall be the user’s responsibility to return to CA the reproduced
copies or to certify to CA that same have been destroyed.
To the extent permitted by applicable law, CA provides this documentation “as is” without warranty of any kind,
including without limitation, any implied warranties of merchantability, fitness for a particular purpose or
noninfringement. In no event will CA be liable to the end user or any third party for any loss or damage, direct or
indirect, from the use of this documentation, including without limitation, lost profits, business interruption,
goodwill, or lost data, even if CA is expressly advised of such loss or damage.
The use of any product referenced in this documentation and this documentation is governed by the end user’s
applicable license agreement.
Provided with “Restricted Rights” as set forth in 48 C.F.R. Section 12.212, 48 C.F.R. Sections 52.227-19(c)(1) and (2) or
DFARS Section 252.227.7013(c)(1)(ii) or applicable successor provisions.
All trademarks, trade names, service marks, and logos referenced herein belong to their respective companies.
Contents
Chapter 1: Overview
COOL:Gen Concepts and Terminology ........................................................ 1-1
Target Audience ............................................................................. 1-3
Contents iii
Chapter 5: Asynchronous Processing with COOL:Gen Proxies
Proxy Interface ............................................................................... 5-1
Synchronous Processing .................................................................. 5-1
Asynchronous Processing ................................................................. 5-1
COOL:Gen Proxies ........................................................................... 5-2
Appendix A: WRASYNCSRVRERROR
Using the User Exit .......................................................................... A-1
Index
Overview
1
This document describes the use of Asynchronous Processing with COOL:Gen
distributed processing applications. It gives an overview of the processing option
prior to COOL:Gen 6.0 (that is, Synchronous Processing), and provides a high-
level overview of the options and design considerations that an application
developer needs to think about before implementing the various options
available with asynchronous processing.
Overview 1–1
COOL:Gen Concepts and Terminology
A Distributed Processing Server (DPS) is the target of a DPC request. The DPS is
a non-GUI server procedure step that, typically, contains business logic and
provides an interface to database information. With COOL:Gen you can generate
server managers that contain one or more target procedure steps.
Server-to-Server Flow Some DPS runtime environments (for example MQSeries, TUXEDO, DCE,
TXSeries, CICS, and IMS) support the situation where one DPS component
initiates a request of another DPS component. These DPS-to-DPS flows are
known as Server-to-Server flows. For server environments that support server-
to-server flows between separate server managers, the flow behaves similarly
to that for a client-to-server flow, and concepts described in this document
apply to both DPC-to-DPS and DPS-to-DPS cooperative flows.
Note: For DPS-to-DPS flows within the same server manager, the flow
processing is treated as a local function call.
Asynchronous COOL:Gen 6.0 provides the option to use asynchronous processing. This allows
processing a requesting application component to be given control immediately after a
flow request is made, so that it can continue with other processing while the
target server is processing an outstanding request. It also means that an
application can initiate cooperative flows without any obligation to process the
corresponding response, so allowing a "fire-and-forget" capability in
COOL:Gen applications.
With COOL:Gen 6.0, the model action language and proxy interfaces have been
extended to support asynchronous processing behavior. Four new action
language statements allow asynchronous behavior to be modeled into both a
generated DPC (GUI) application, and to a generated DPS application that, in
this case, is limited to those server environments that support server-to-server
flows.
The three proxy environments (C Proxy, COM Proxy, and Java Proxy), have also
been modified to support similar asynchronous behavior as that provided to a
generated GUI application via the new asynchronous action language
statements.
Target Audience
This document will be of use to experienced COOL:Gen developers who want to
explore the use of asynchronous cooperative flows. Developing applications that
use asynchronous cooperative flows is complicated, because the logic necessary
to request the services of a target procedure is separate from the logic involved
in retrieving the response. The mechanics of initiating and completing the
cooperative flow becomes the responsibility of the application developer.
Additionally, the application developer is given the opportunity to provide the
logic for handling errors.
Overview 1–3
Chapter
Asynchronous Processing with
2 COOL:Gen
Synchronous Processing
From the perspective of the requesting application component (the client), a
remote procedure (PStep) executes as one atomic, blocked operation. When a
request is initiated, the requesting application component is blocked while
control passes through the various application components, and the
corresponding response is returned. The requesting application component can
not proceed with other processing until the synchronous cooperative flow is
complete, and control is returned from the specified target server PStep back to
the client. A DPC expects that any request will always be satisfied with a
corresponding response. The following illustration shows the cooperative flow
that takes place when a windows client issues a synchronous request to a Server
Manager. In this case, the windows client must wait until it receives a response
to its request from the server.
Asynchronous Processing
In general, asynchronous processing is based on a similar concept of a
cooperative flow (that is, request/response). However, asynchronous processing
allows you to decouple the handling of the request from the handling of the
response. The effect of an asynchronous request is to initiate the server
processing; the requesting application must then explicitly retrieve (or ignore)
the request's associated asynchronous response.
The request stage comprises the initiating request for the asynchronous flow
(stage 1a) followed by a request to the server to process the request (stage 1b).
Note that the scope of the initiating request (stage 1a) is dependent on the
middleware being used, the middleware being the deciding factor on where the
"hand over" from stage 1a to stage 1b occurs. The retrieval stage (stage 2)
comprises a request from the client to retrieve, or check the status of, the
supplied response.
Asynchronous Behavior
3
COOL:Gen applications using synchronous processing use the PStep USE
statement to request a cooperative flow. The PStep USE statement operates as
one atomic operation by sending a view, waiting for a response, and receiving a
view.
Asynchronous Commands
4
This chapter defines the method of operation of each of the asynchronous
commands. For details on the individual commands, click on the command
name.
■ USE ASYNC—initiates an asynchronous request.
■ GET ASYNC RESPONSE—retrieves an asynchronous response.
■ CHECK ASYNC RESPONSE—checks whether a response is available.
■ IGNORE ASYNC RESPONSE—ignores a response.
See the description of each of the above ASYNC statements for the behavior that
results if a particular WHEN clause is present or is deleted.
USE ASYNC
This command description includes:
■ The syntax of the command
■ A description of the parameters
■ Related examples.
Syntax
+--USE ASYNC target_pstep (procedure step)
| WHICH IMPORTS:...
| IDENTIFIED BY: viewname async_request
| RESPONSE HANDLING: POLL | NOTIFY EVENT | NO RESPONSE
| RESPONSE EVENT: eventhandlername
| RESPONSE SCOPE: PSTEP | GLOBAL
+--WHEN request accepted
+--WHEN request not accepted
As with a USE PStep, the USE ASYNC statement must specify an import view
that identifies the data to be sent to the server PStep.
Note: A USE ASYNC statement can only be used to flow to a procedure step
that is packaged in a server manager. The USE ASYNC command does not
support a flow from a windowed client to a non-windowed client.
The optional set of WHEN clauses on the USE ASYNC statement give the
application developer control that is not available with a synchronous
cooperative flow. Each of the WHEN clauses is included in the code when a USE
ASYNC statement is constructed by the PAD editor. You can delete either or
both of the WHEN clauses.
If this clause is not present, processing continues with the first statement
following the USE ASYNC.
WHEN request not accepted—The code contained in this WHEN clause is given
control if the supporting runtime encounters an error attempting to initiate the
asynchronous cooperative flow. The ERROR_MESSAGE field, of the specified
ASYNC_REQUEST view, contains a message explaining why the given request
was not accepted for processing.
If deleted, the runtime terminates the initiating PStep. This process is similar to
an error occurring during a failed USE Procedure Step statement. The currently
executing code block is exited.
Response Handling
Notify Event A RESPONSE HANDLING clause specified as NOTIFY EVENT indicates that
the application will be notified when a response to an event is received by the
supporting runtime. The event notification is handled in a similar way to
existing window events. You must first specify that the application wishes to be
notified, by specifying a value of NOTIFY EVENT for the RESPONSE
HANDLING clause on the USE ASYNC statement. Additionally, you must
associate an event handler with each asynchronous request that specifies an
event be raised. The event handler name is supplied via the RESPONSE EVENT
clause on the requesting USE ASYNC statement. A unique event type is created
for each given instance of the USE ASYNC statement. This unique event type is
associated with the specified event handler that has been specified using the
RESPONSE EVENT clause.
When you add a NOTIFY EVENT type USE ASYNC statement, you can create a
new EVENT ACTION block, or select an existing EVENT ACTION already
associated with the PStep.
Note: The runtime only provides notice that the request has completed. This
does not imply that the request completed successfully.
As with other window events, the PStep can only receive a given event when it
has at least one open window. The open window is needed to send the event to
the event action block that has been defined to handle the specified event type. If
the window is closed, the event notification is ignored, and the response is
retained or discarded depending on the response scope of the call. That is, the
response is discarded if the response scope is PSTEP, and retained if the scope is
GLOBAL. (See Response Scope.)
For example, the logic doing the polling may complete the request prior to the
event handler being scheduled. The logic in the event handler, assuming it
attempts to complete the request, must be coded to cope with the fact that the
request that causes the event handler to be driven might, in fact, already be
complete.
No Response
Response Scope
Contrary to the cleanup provided for the default scope of PSTEP (that is, where
the request is considered complete), the runtime does not implicitly complete an
outstanding request where the response scope is marked as GLOBAL. You must
include application logic that is responsible for completing requests that indicate
their associated response have a GLOBAL scope. That is, the application logic
must issue either a GET ASYNC RESPONSE or an IGNORE ASYNC RESPONSE
to complete the request.
Note: The COOL:Gen 6.0 Server Runtime only supports a RESPONSE SCOPE of
PSTEP. That is, a response to an outstanding request cannot linger across
invocations of a target server PStep. All asynchronous cooperative flows
initiated by a server PStep (that is, server-to-server flows) must be completed
explicitly by the server PStep code, or implicitly by the Server Runtime, prior to
returning control to the invoking client application component.
Examples
The Toolset's Action Diagram helps construct the USE ASYNC statement. The
following examples show the various types of USE ASYNC:
1. An asynchronous request indicating that the application does not wish to
receive the response associated with the request:
+--USE ASYNC target_pstep (procedure step)
| WHICH IMPORTS: ...
| IDENTIFIED BY: viewname async_request
| RESPONSE HANDLING: NO RESPONSE
+--WHEN request accepted
+--WHEN request not accepted
+--
5. This example also shows the EVENT ACTION block that is created when the
USE ASYNC statement was created. The name of the EVENT ACTION is
automatically assigned to be the same as the target_pstep referenced on the
USE ASYNC statement. If the application developer wishes to create a new
EVENT ACTION (as opposed to using a previously defined EVENT
ACTION) and if for some reason an EVENT ACTION already exists with the
target-pstep name, the Toolset will create a unique name for the new EVENT
ACTION (for example, adding a 1, 2, 3, and so on).
+--USE ASYNC target_pstep (procedure step)
| WHICH IMPORTS: ...
| IDENTIFIED BY: viewname ASYNC_REQUEST
| RESPONSE HANDLING: NOTIFY EVENT
| RESPONSE EVENT: target_pstep
| RESPONSE SCOPE: PSTEP
+--WHEN request accepted
+--WHEN request not accepted
+--
.
.
.
+--EVENT ACTION target_pstep
|
+--
Syntax
+--GET ASYNC RESPONSE target_pstep (procedure step)
| WHICH EXPORTS:...(syntax the same as USE PStep)
| IDENTIFIED BY: viewname async_request
+--WHEN successful
+--WHEN pending
+--WHEN invalid ASYNC_REQUEST_ID
+--WHEN server error
+--WHEN communications error
Note: Depending on the application's logic, it may be more efficient to use the
CHECK ASYNC RESPONSE statement, followed by the GET ASYNC
RESPONSE statement. The check statement is simply a status check, and does
not incur any of the resource overheads associated with the get response
statement (for example, storage for the response message object). However, this
processing may be offset by the increased processing time used if the application
loops, repeating a check statement.
The application must keep track of each outstanding request, so that it can obtain
obtain a given request's corresponding response. The application indicates the
response by the specified ASYNC_REQUEST view. The specified
ASYNC_REQUEST Work Set view should be the same view (or at least a view
that contains the same values) as was specified on the USE ASYNC statement
that initiated the original asynchronous flow.
The optional set of WHEN clauses on the GET ASYNC RESPONSE statement,
give you processing control that is not available with a synchronous cooperative
flow. For example, you may not want to interrupt the application's current
processing if an error is detected during the handling of an asynchronous
request. Compare this with the processing of a synchronous cooperative flow,
where errors are handled by the runtime servicing the flow, and the processing
of the initiating PStep is aborted if the runtime detects an error in either the
handling of the request or in the actual processing of the target PStep code (that
is, an XFAL).
When executing the GET ASYNC RESPONSE statement, the process flow gives
control to an applicable WHEN clause, if it is present. When the block of code
associated with the WHEN clause has completed, processing continues with the
statement immediately after the GET ASYNC RESPONSE statement. All of the
WHEN clauses are included in the code when the GET ASYNC RESPONSE
statement is constructed by the PAD editor. You can delete any of the WHEN
clauses, as required.
Syntax
+--CHECK ASYNC RESPONSE
| IDENTIFIED BY: viewname async_request
+--WHEN available
+--WHEN pending
+--WHEN invalid ASYNC_REQUEST_ID
If the application just needs to check the status of a response, using CHECK
ASYNC RESPONSE is more efficient, and faster, than using GET ASYNC
RESPONSE as it does not need to allocate (then de-allocate) any resources (for
example, storage for the response message object).
When executing the CHECK ASYNC RESPONSE statement, the process flow
gives control to an applicable WHEN clause, if it is present. When the block of
code associated with the WHEN clause has completed, processing continues
with the statement immediately after the CHECK ASYNC RESPONSE statement.
All of the WHEN clauses are included in the code when the CHECK ASYNC
RESPONSE statement is constructed by the PAD editor. You can delete any of
the WHEN clauses, as required.
IGNORE ASYNC
This command description includes:
■ The syntax of the command
■ A description of the parameters
Syntax
+--IGNORE ASYNC RESPONSE
| IDENTIFIED BY: viewname async_request
+--WHEN invalid ASYNC_REQUEST_ID
It is likely that an application will, at some point, have one or more outstanding
asynchronous requests that it no longer wishes to process. You can use the
IGNORE ASYNC RESPONSE statement to inform the runtime that the
application wishes to ignore the response corresponding to the specified
ASYNC_REQUEST.
However, the runtime will continue to keep track of an ignored request, as the
resources associated with an ignored request remain allocated as long as the
ignored request's corresponding response remains outstanding. Only when the
response is received (that is, the request is complete), can the runtime free the
resources associated with the request.
Proxy Interface
The fundamental concept of how you use a proxy is the same whether you are
implementing synchronous or asynchronous cooperative flow.
Synchronous Processing
With synchronous processing, the client code that invokes the interface remains
blocked until it receives a corresponding response. Like the USE PStep
statement, a proxy's execute interface is processed as an atomic operation.
Asynchronous Processing
With COOL:Gen 6.0, a user-written client application can make and receive
requests from a server in an asynchronous manner. The set of exposed proxy
interfaces includes APIs that provide a non-generated client application with the
ability to communicate with a target DPS in an asynchronous fashion.
COOL:Gen Proxies
COOL:Gen supports three types of proxies:
■ The ActiveX/COM Proxy is a generated COM object that provides an
automation interface to COOL:Gen servers. Providing a COM automation
interface allows Web applications with Active Server Pages and any OLE-
enabled client access to COOL:Gen servers.
■ Asynchronous behavior is supported by a set of common properties and
methods in the generated COM Proxy interface and the COM Proxy
Runtime. A client application, that wishes to take advantage of a given COM
Proxy's asynchronous processing, must invoke its exposed asynchronous
interface method. See the ActiveX/COM and java Proxies document for details
of generating and using an ActiveX/COM Proxy.
■ The Java Proxy is a Java-based interface that allows Java applets and Java
application to re-use COOL:Gen servers.
■ Asynchronous behavior is supported by a set of common properties and
methods in the generated Client Java Bean and Application Java Bean. An
applet or application, that wishes to take advantage of a given Java Proxy's
asynchronous processing, must invoke the respective bean's exposed
asynchronous interface methods. See the ActiveX/COM and java Proxies
document for details of generating and using a Java Proxy.
■ The C Proxy API is a generated C language header file that provides you
with the flexibility to call COOL:Gen server components from a C language
application, or applications that support a C language interface.
■ The C Proxy Runtime contains a set of APIs that support asynchronous
behavior. A client application wishing to use asynchronous processing must
use the specific asynchronous function calls, as described in the C Proxy API
document.
WRASYNCSRVRERROR
A
In GUI processing, the User Exit WRASYNCSRVRERROR is invoked when an
error is detected during the processing of an asynchronous cooperative flow.
This may be in response to the USE ASYNC, GET ASYNC RESPONSE, CHECK
ASYNC RESPONSE or IGNORE ASYNC RESPONSE statements. This user exit
allows the client to detect the error, analyze the problem and possibly recover.
The default behavior of this exit is to display the error dialog only if the
executing COOL:Gen statement does not have a WHEN clause coded that
corresponds to the exception condition encountered.
If you wish to display the error dialog, even if the WHEN exception clause is
coded, the user exit can be customized to display this behavior. However, in this
case, the error dialog is enabled regardless of which of the possible exception
conditions occur within the application.
It is possible to customize this user exit to contain specific processing rules and
conditions.
WRASYNCSRVRERROR A–1
Appendix
COOL:Gen Glossary
For definitions of new terminology used in this document, see the COOL:Gen
Glossary in the Toolset help system.
A P
REASON_CODE, 3-1
I
Server-to-Server, 1-1
J
Synchronous Processing, 1-1
T
N
Target Audience, 1-1
OLE-enabled, 5-1
Overview, 1-1
Index–1
U W