![]() | Programming Guide | ![]() |
Returns from a service request invocation
service_return [returnStatus] ([message]) [CODEreturnCode]
returnStatus- Specifies the service return status with one of these values:
SUCCESS—The service succeeded.
EXIT—The service failed and the server executable should terminate.
Under Oracle Tuxedo, the middleware uses the service's return status to determine whether a transaction is successful. If any service that participates in a transaction returns with
FAILUREorEXIT, the transaction is marked as abort-only. The transaction cannot be committed and must be aborted explicitly by the user.For more information about transactions, refer to xa_begin and xa_end
message- Specifies the message data to return to the invoking agent. This provides a mapping from Panther variables to the return arguments specified in the service call. Always enclose the data in message in parentheses even if no data is specified. The message format is determined by the transport method specified for the service in the JIF:
JAMFLEX,STRINGor anFMLbuffer.For more information on message data, refer to "Service Messages and Data Types" in JetNet/Oracle Tuxedo Guide.
CODEreturnCode- An integer to associate with the return. This code can be examined by the client agent; it is ignored by the middleware. If omitted, the default return value is
0.
JetNet, Oracle Tuxedo
Server
The
service_returncommand returns data from a service request and indicates to the middleware whether the service was performed successfully.service_returnand service_forward are the only commands by which a service can be explicitly completed. If a service routine terminates without using either of these, Panther completes the service automatically as if theservice_returncommand were invoked with an empty argument list, with areturnCodeequal to the return value from the service routine, and with areturnStatusof eitherFAILURE(if the service return value is negative), orSUCCESS(if the return value is0or greater).All properties are restored to default settings after execution of
service_return, since the service routine will have terminated.On the client side, the
tp_svc_outcomeproperty is set to the service's return status, where it can be inspected by the client. Thetp_svc_returnproperty is set to the return code.The
tp_tran_statusproperty is set toTP_WILL_ABORTif the service returned with aFAILUREorEXITstatus.
If the JIF defines a service to use the transaction manager, any data that the transaction manager returns is automatically appended to the message argument. For example, service
customer_sspecifiesSelectas its transaction type. When that service returns, the middleware appends the query results to the reply message.If a transaction returns data to the client, the
service_returncall must specify a message argument. Thus, a service that specifiesSelectas its transaction type returns (if successful) with the results of the database query, soservice_returnmust specify a message argument; conversely, aDeletetransaction returns no data to the client, so aservice_returncommand that returns from a service of that transaction type can omit its message argument.If a transaction returns data and the
service_returncommand has no message data of its own, the command must use the default mapping format for its message arguments:{...}. For example:service_return SUCCESS ({...})
service_returncan generate the following exceptions:
If, during processing of a
service_returncommand, an exception of severityTP_ERRORor greater occurs before control returns to the middleware, the service is completed with an error return status. Panther ensures an error return status by using aFAILUREstatus unless theservice_returncommand explicitly specifies anEXITstatus, in which case anEXITstatus is used.
The following code is the
DEPOSITservice. The client side of this process is shown in the xa_end command.proc deposit()
// service DEPOSIT
vars amount
receive arguments ({account_id, amount})
call sm_tm_command("SELECT")if (!@dmrowcount)
{
service_return failure ({message = "Invalid account."})
}
// need to check that overflow will not happen when
// depositing
if (account_balance + amount > max_balance)
{
service_return failure \
({message = "Balance field overflow"})
}
account_balance = account_balance + amount
call sm_tm_command("SAVE")
service_return ({message = @tpi_null, \
balance = account_balance})
service_call, service_forward, xa_begin, xa_end
![]()
![]()
![]()
![]()