Writing a back-end transaction program
The back-end transaction (in this sample, a TP running on the workstation) is initiated as a result of the front-end transaction's connectUsing: method.
Step 1: Accepting the conversation
The back-end transaction can choose either to accept the conversation or to reject it. If the conversation is accepted, the back-end transaction needs to allocate an instance of AbtAPPCConversation on its end of the conversation. You can use the receiveAllocate: method from the AbtAPPCLocalTP class to accept and allocate a conversation. Note that the TP you are allocating is the same TP the front-end transaction indicated in method partnerTPName:.
| conversation |
"Accept and allocate a conversation"
conversation := AbtAPPCLocalTP receiveAllocate: 'NEWNAME'.
"Verify the conversation"
conversation isCommunicationsError
ifTrue: [conversation display].
Step 2: Retrieving conversation characteristics
Use the getAttributes method of the AbtAPPCConversation class to return an AbtAPPCConnectionSpec object containing the learned attributes. By using the getAttributes method, the back-end transaction can determine the attributes with which the conversation was allocated by the front-end transaction.
| allocationValues |
"Obtain the values with which the conversation was allocated"
allocationValues := conversation getAttributes.
Step 3: Receiving data from the front-end transaction
Once the conversation is accepted, the back-end transaction should use the receive methods of the AbtAPPCConversation class. You can use the receiveAndWait methods to wait for inbound data to arrive or use the receiveImmediate methods to receive any data that is available without waiting. Note that the receive methods for the front-end and back-end transactions can be identical.
| receiveData |
"Receive data when provided by the back-end transaction"
receiveData := conversation receiveAndWaitDataComplete.
"Check outcome of receiveData"
The result of a receiveAndWait is an APPCReception object, which contains not only the raw data received, but also APPC status information. You can use the methods of APPCReceptionObject to retrieve this information.
The back-end transaction can now use the
send methods to send data to the front-end transaction in the same manner the front-end transaction sends data to the back-end transaction. See
Step 3: Sending data to the partner transaction. Also, the back-end transaction can end the conversation in the same way the front-end transaction requests the conversation be ended. See
Step 5: Ending the conversation.
Last modified date: 01/29/2015