6 Oracle WebLogic Tuxedo Connector JATMI Conversations
Note:
See Writing Conversational Clients and Servers in Programming a Tuxedo ATMI Application in C at http://docs.oracle.com/cd/E13203_01/tuxedo/tux100/pgc/pgconv.html
.
This chapter includes the following sections:
- Overview of Oracle WebLogic Tuxedo Connector Conversational Communication
- Oracle WebLogic Tuxedo Connector Conversation Characteristics
- Oracle WebLogic Tuxedo Connector JATMI Conversation Primitives
- Creating Oracle WebLogic Tuxedo Connector Conversational Clients and Servers
- Sending and Receiving Messages
- Ending a Conversation
- Executing a Disorderly Disconnect
- Understanding Conversational Communication Events
- Oracle WebLogic Tuxedo Connector Conversation Guidelines
Overview of Oracle WebLogic Tuxedo Connector Conversational Communication
Oracle WebLogic Tuxedo Connector supports Oracle Tuxedo conversations as a method to exchange messages between Oracle WebLogic Server and Oracle Tuxedo applications. In this form of communication, a virtual connection is maintained between the client and the server and each side maintains information about the state of the conversation. The process that opens a connection and starts a conversation is the originator of the conversation. The process with control of the connection is the initiator; the process without control is called the subordinate. The connection remains active until an event occurs to terminate it.
During conversational communication, a half-duplex connection is established between the initiator and the subordinate. Control of the connection is passed between the initiator and the subordinate. The process that has control can send messages (the initiator); the process that does not have control can only receive messages (the subordinate).
Parent topic: Oracle WebLogic Tuxedo Connector JATMI Conversations
Oracle WebLogic Tuxedo Connector Conversation Characteristics
Oracle WebLogic Tuxedo Connector JATMI conversations have the following characteristics:
-
Data is passed using TypedBuffers. The type and sub-type of the data must match one of the types and sub-types recognized by the service.
-
The logical connection between the conversational client and the conversational server remains active until it is terminated.
-
Any number of messages can be transmitted across a connection between a conversational client and the conversational server.
-
A Oracle WebLogic Tuxedo Connector conversational client initiates a request for service using tpconnect rather than a tpcall or tpacall.
-
Oracle WebLogic Tuxedo Connector conversational clients and servers use the JATMI primitives tpsend to send data and tprecv to receive data.
-
A conversational client only sends service requests to a conversational server.
-
Conversational servers are prohibited from making calls to
tpforward
.
Parent topic: Oracle WebLogic Tuxedo Connector JATMI Conversations
Oracle WebLogic Tuxedo Connector JATMI Conversation Primitives
Use the following Oracle WebLogic Tuxedo Connector primitives when creating conversational clients and servers that communicate between Oracle WebLogic Server and Oracle Tuxedo:
Table 6-1 Oracle WebLogic Tuxedo Connector Conversational Client Primitives
Name | Operation |
---|---|
Use to establish a connection to an Oracle Tuxedo conversational service. |
|
Use to abort a connection and generate a TPEV_DISCONIMM event. |
|
Use to receive data across an open connection from an Oracle Tuxedo application. |
|
Use to send data across a open connection to an Oracle Tuxedo application. |
Parent topic: Oracle WebLogic Tuxedo Connector JATMI Conversations
Creating Oracle WebLogic Tuxedo Connector Conversational Clients and Servers
The following sections provide information on how to create conversational clients and servers.
Parent topic: Oracle WebLogic Tuxedo Connector JATMI Conversations
Creating Conversational Clients
Follow the steps outlined in Developing Oracle WebLogic Tuxedo Connector Client EJBs to create Oracle WebLogic Tuxedo Connector conversational clients. The following section provide information on how to use tpconnect to open a connection and start a conversation.
Establishing a Connection to an Oracle Tuxedo Conversational Service
A Oracle WebLogic Tuxedo Connector conversational client must establish a connection to the Oracle Tuxedo conversational service. Use the JATMI primitive tpconnect to open a connection and start a conversation. A successful call returns an object that can be used to send and receive data for a conversation.
The following table describes tpconnect
parameters:
Table 6-2 Oracle WebLogic Tuxedo Connector JATMI tpconnect Parameters
Parameter | Description |
---|---|
|
Character pointer to a conversational service name. If you do not specify a |
|
Pointer to the data buffer. When establishing a connection, you can send data simultaneously by setting the |
|
Use flags or combinations of flags as required by your application needs. Valid flag values are: TPSENDONLY: specifies that the control is being retained by the originator. The called service is subordinate and can only receive data. Do not use in combination with TPRECVONLY: specifies that control is being passed to the called service.The originator becomes subordinate and can only receive data. Do not use in combination with TPNOTRAN: specifies that when TPNOBLOCK: specifies that a request is not sent if a blocking condition exists. If TPNOTIME: specifies that the originator will block indefinitely and is immune to blocking timeouts. If the originator is in transaction mode, the call is subject to transaction timeouts. |
Parent topic: Creating Conversational Clients
Example TuxedoConversationBean.java Code
The following provides a code example to use tpconnect to start a conversation:
Example 6-1 Example Conversation Code
. . . Context ctx; Conversation myConv; TuxedoConnection myTux; TuxedoConnectionFactory tcf; . . . ctx = new InitialContext(); tcf = (TuxedoConnectionFactory) ctx.lookup ("tuxedo.services.TuxedoConnection"); myTux = tcf.getTuxedoConnection(); flags =ApplicationToMonitorInterface.TPSENDONLY; myConv = myTux.tpconnect("CONNECT_SVC",null,flags); . . .
Parent topic: Creating Conversational Clients
Creating Oracle WebLogic Tuxedo Connector Conversational Servers
Follow the steps outlined in Developing Oracle WebLogic Tuxedo Connector Service EJBs, to create Oracle WebLogic Tuxedo Connector conversational servers.
Sending and Receiving Messages
Once a conversational connection is established between a Oracle WebLogic Server application and an Oracle Tuxedo application, the communication between the initiator (sends message) and subordinate (receives message) is accomplished using send and receive calls. The following sections describe how Oracle WebLogic Tuxedo Connector applications use the JATMI primitives tpsend and tprecv:
Parent topic: Oracle WebLogic Tuxedo Connector JATMI Conversations
Sending Messages
Use the JATMI primitive tpsend to send a message to an Oracle Tuxedo application.
The following table describes tpsend
parameters:
Table 6-3 Oracle WebLogic Tuxedo Connector JATMI tpconnect Parameters
Parameter | Description |
---|---|
|
Pointer to the buffer containing the data sent with this conversation. |
|
The flag can be one of the following: TPRECVONLY: specifies that after the initiator's data is sent, the initiator gives up control of the connection. The initiator becomes subordinate and can only receive data. TPNOBLOCK: specifies that the request is not sent if a blocking condition exists. If TPNOTIME: specifies that an initiator is willing to block indefinitely and is immune from blocking timeouts. The call is subject to transaction timeouts. |
Parent topic: Sending and Receiving Messages
Receiving Messages
Use the JATMI primitive tprecv to receive messages from an Oracle Tuxedo application.
The following table describes tprecv
parameters:
Table 6-4 Oracle WebLogic Tuxedo Connector JATMI tprec Parameters
Parameter | Description |
---|---|
|
The flag can be one of the following: TPNOBLOCK: specifies that TPNOTIME: specifies that A flag value of 0 specifies that the initiator blocks until the condition subsides or a timeout occurs. |
Parent topic: Sending and Receiving Messages
Ending a Conversation
A conversation between Oracle WebLogic Server and Oracle Tuxedo ends when the server process successfully completes its tasks. The following sections describe how a conversation ends:
- Oracle Tuxedo Application Originates Conversation
- Oracle WebLogic Tuxedo Connector Application Originates Conversation
- Ending Hierarchical Conversations
Parent topic: Oracle WebLogic Tuxedo Connector JATMI Conversations
Oracle Tuxedo Application Originates Conversation
An Oracle WebLogic Server conversational server ends a conversation by a successful call to return
. A TPEV_SVCSUCC event is sent to the Oracle Tuxedo client that originated connection to indicate that the service finished successfully. The connection is then disconnected in an orderly manner.
Parent topic: Ending a Conversation
Oracle WebLogic Tuxedo Connector Application Originates Conversation
An Oracle Tuxedo conversational server ends a conversation by a successful call to tpreturn
. A TPEV_SVCSUCC event is sent to the Oracle WebLogic Tuxedo Connector client that originated connection to indicate that the service finished successfully. The connection is then disconnected in an orderly manner.
Parent topic: Ending a Conversation
Ending Hierarchical Conversations
The order in which an conversation ends is important to gracefully end hierarchal conversations.
Assume there are two active connections: A-B and B-C. If B is a Oracle WebLogic Tuxedo Connector application in control of both connections, a call to return
has the following effect: the call fails and 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 in an orderly manner, the application must execute the following sequence:
-
B calls tpsend with TPRECVONLY to transfer control of the B-C connection to the Oracle Tuxedo application C.
-
C calls
departure
withrval
set toTPSUCCESS
,TPFAIL
, orTPEXIT
. -
B calls
return
and posts an event (TPEV_SVCSUCC or TPEV_SVCFAIL) for A.
Conversational services can make request/response calls. Therefore, in the preceding example, the calls from B to C may be executed using tpacall() or tpcall() instead of tpconnect. Conversational services are not permitted to make calls to tpforward
.
Parent topic: Ending a Conversation
Executing a Disorderly Disconnect
Oracle WebLogic Server conversational clients or servers execute a disorderly disconnect is through a call to tpdiscon. This is the equivalent of "pulling the plug" on a connection.
A call to tpdiscon
:
-
Immediately tears down the connection and generates a TPEV_DISCONIMM at the other end of the connection. Any data that has not yet reached its destination may be lost. If the conversation is part of a transaction, the transaction must be rolled back.
-
Can only be called by the initiator of the conversation.
Parent topic: Oracle WebLogic Tuxedo Connector JATMI Conversations
Understanding Conversational Communication Events
Oracle WebLogic Tuxedo Connector JATMI uses five events to manage conversational communication. The following table lists the events, the functions for which they are returned, and a detailed description of each.
Table 6-5 Oracle WebLogic Tuxedo Connector Conversational Communication Events
Event | Received by | Description |
---|---|---|
Tuxedo |
Control of the connection has passed; this Oracle Tuxedo process can now call |
|
JATMI |
Control of the connection has passed; this JATMI process can now call |
|
Tuxedo |
The connection has been torn down and no further communication is possible. The JATMI |
|
JATMI |
The connection has been torn down and no further communication is possible. The Oracle Tuxedo |
|
Tuxedo |
Received by the originator of the connection indicating that the subordinate program issued a |
|
Tuxedo |
Received by the originator of the connection indicating that the subordinate program issued a successful |
|
Tuxedo |
Received by the originator of the connection, indicating that the subordinate service finished successfully; that is, |
|
JATMI |
Received by the originator of the connection, indicating that the subordinate service finished successfully; that is, |
|
Tuxedo |
Received by the originator of the connection indicating that the subordinate program issued a |
|
Tuxedo |
Received by the originator of the connection indicating that the subordinate program finished unsuccessfully. The service completed with status of TPFAIL or TPEXIT. |
Parent topic: Oracle WebLogic Tuxedo Connector JATMI Conversations
Oracle WebLogic Tuxedo Connector Conversation Guidelines
Use the following guidelines while in conversation mode to insure successful completion of a conversation:
-
Use the JATMI conversational primitives as defined in the Oracle WebLogic Tuxedo Connector Conversation interface and ApplicationToMonitorInterface interface.
-
Always use a flag.
-
Only use flags defined in the Oracle WebLogic Tuxedo Connector JATMI.
-
-
Oracle WebLogic Tuxedo Connector does not have a parameter that can be used to limit the number of simultaneous conversations to prevent overloading the Oracle WebLogic Server network.
-
If Oracle Tuxedo exceeds the maximum number of possible conversations (defined by the
MAXCONV
parameter), TPEV_DISCONIMM is the expected Oracle WebLogic Tuxedo Connector exception value. -
A tprecv to an unauthorized Oracle Tuxedo service results in a TPEV_DISCONIMM exception value.
-
If a Oracle WebLogic Tuxedo Connector client is connected to an Oracle Tuxedo conversational service which does
tpforward
to another conversational service, TPEV_DISCONIMM is the expected Oracle WebLogic Tuxedo Connector exception value. -
Conversations may be initiated within a transaction. Start the conversation as part of the program statements in transaction mode. See Oracle WebLogic Tuxedo Connector JATMI Transactions.
-
If an Oracle WebLogic Tuxedo Connector remote domain experiences a TPENOENT, the remote domain will send back a disconnect event message and be caught on the Oracle WebLogic Tuxedo Connector application tprecv as a TPEV_DISCONIMM exception.
Parent topic: Oracle WebLogic Tuxedo Connector JATMI Conversations