![]() |
![]() |
|
|
Ending a Conversation
A connection can be taken down gracefully and a conversation ended normally through:
Note: The tpreturn() function is described in detail in Writing Request/Response Clients and Servers.
The following sections describe two scenarios for gracefully terminating conversations that do not include global transactions in which the tpreturn() function is used.
The first example shows how to terminate a simple conversation between two components. The second example illustrates a more complex scenario, with a hierarchical set of conversations.
If you end a conversation with connections still open, the system returns an error. In this case, either tpcommit() or tpreturn() fails in a disorderly manner.
Example: Ending a Simple Conversation
The following diagram shows a simple conversation between A and B that terminates gracefully.
Simple Conversation Terminated Gracefully
The program flow is as follows:
Note: In this example, A can be either a client or a server, but B must be a server.
Example: Ending a Hierarchical Conversation
The following diagram shows a hierarchical conversation that terminates gracefully.
Connection Hierarchy
In the preceding example, service B is a member of a conversation that has initiated a connection to a second service called C. In other words, there are two active connections: A-to-B and B-to-C. If B is in control of both connections, a call to tpreturn() has the following effect: the call fails, a TPEV_SVCERR event is posted on all open connections, and the connections are closed in a disorderly manner. In order to terminate both connections normally, an application must execute the following sequence:
Note: It is legal for a conversational service to make request/response calls if it needs to do so to communicate with another service. Therefore, in the preceding example, the calls from B to C may be executed using tpcall() or tpacall() instead of tpconnect(). Conversational services are not permitted to make calls to tpforward().
Executing a Disorderly Disconnect
The only way in which a disorderly disconnect can be executed is through a call to the tpdiscon(3c) function (which is equivalent to "pulling the plug" on a connection). This function can be called only by the initiator of a conversation (that is, the client).
Note: This is not the preferred method for bringing down a conversation. To bring down an application gracefully, the subordinate (the server) should call the tpreturn() function.
Use the following signature to call the tpdiscon() function:
int
tpdiscon(int cd)
The cd argument specifies the connection descriptor returned by the tpconnect() function when the connection is established.
The tpdiscon() function generates a TPEV_DISCONIMM event for the service at the other end of the connection, rendering the cd invalid. If a transaction is in progress, the system aborts it and data may be lost.
If tpdiscon() is called from a service that was not the originator of the connection identified by cd, the function fails with an error code of TPEBADDESC.
For a list and descriptions of all event and error codes, refer to tpdiscon(3c) in the BEA Tuxedo ATMI C Function Reference.
![]() |
![]() |
![]() |
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|