Programming Guide



wait

Waits for service calls to return before processing resumes

Synopsis

wait [serviceCalls] [ TIMEOUT timeout]

Arguments

serviceCalls
Specifies which service calls must return before processing resumes. If no service calls are specified, processing is suspended until the current service call returns. Use one of these keywords and its options:

FOR [callid]
Processing resumes when service call callid returns.

FOR_ALL [callSpec]
Processing resumes when all the specified services return. If you omit callSpec, all outstanding service calls must return in order to resume processing. callSpec can have one of these formats:

FOR_ANY [callSpec]
Processing resumes when one of the specified services return. If you omit callSpec, processing resumes when any outstanding service call returns. callSpec can have one of these formats:

TIMEOUT timeout
Resume processing if the specified service calls do not return before timeout elapses. timeout is a quoted string or variable whose format can specify a relative time (time elapsed after the wait command is issued) or an absolute time. If no timeout is specified, all specified service calls must return before processing resumes.

A relative timeout can be specified in this format:

"[ +days hours::minutes::]seconds"

Seconds are required; minutes, hours, or days (space delimiter between days and hours) can also be specified. If more than seconds is specified, the + symbol and the quotation marks are mandatory. If only seconds are specified, both are optional.

Note: JPL's colon preprocessor expands colon-prefixed variables. To prevent expansion of variables that contain colons, you must prefix literal colons with another colon (::) or a backslash (\:).

An absolute timeout can be specified in one of these ways:


Environment

JetNet, Oracle Tuxedo

Scope

Client, Server

Description

The wait command suspends processing of its caller pending completion of the specified service calls or elapse of the specified timeout. If no service calls are specified, processing is suspended until the current service call returns. Processing can resume whether or not the specified calls return with the requested service. When wait returns, it sets the tp_return property to the number of service calls that returned while processing was suspended.

The wait command activates the exception, unload and post_request handlers associated with any call that returns while the wait command executes.

In the following example, the client code issues two service calls, WITHDRAWAL and BAL_INFO, both asynchronous. The wait command includes the FOR_ALL option, which prevents the same client from engaging in any other activity until both service calls return:

vars err_msg
service_call service "WITHDRAWAL"( \
acct_id, \
{err_msg, transact_id, post_date}) ASYNC
service_call service "BAL_INFO"( 	\
acct_id, \
{message, cur_bal, avail_bal, cur_date}) ASYNC
wait FOR_ALL
...

Exceptions

wait can generate these exceptions:

Exception Severity Cause
TP_INVALID_CALL
TP_COMMAND

Invalid callid.

TP_INVALID_CONNECTION
TP_COMMAND

No connection to middleware.

TP_INVALID_OPTION_VALUE
TP_COMMAND

Invalid TIMEOUT specification.

TP_NO_OUTSTANDING_CALLS
TP_INFORMATION

All specified service calls returned.

TP_TIMEOUT
TP_WARNING

The wait command returned because the specified timeout elapsed.

See Also

service_call, receive