Integration Server 10.11 | Guaranteed Delivery Developer’s Guide | Creating a Java Client that Uses Guaranteed Delivery | Sample Code (Synchronous Request)
 
Sample Code (Synchronous Request)
The following code fragment illustrates the basic steps required to submit a synchronous request to the Job Manager. Synchronous requests are submitted using the invokeTx method. You can also submit asynchronous requests to the Job Manager as shown in the next section.
Important:
To compile the following sample code (or any Java client that uses guaranteed delivery), you must include the following import statements in your Java program.

import com.wm.data.*;
import com.wm.app.b2b.client.*;
import com.wm.util.*;
import com.wm.app.b2b.client.lic.*;
#
Step
Description
1
Declare TContext.
Declare TContext as a variable.
2
Initialize TContext.
Initialize TContext and specify the job store directory and audit-trail log. The Job Manager starts.
Important:
Do not include this step if your client will run as a service on a webMethods Integration Server. This function is automatically performed by the server and must not be included in your code.
3
Instantiate TContext.
Create a new TContext object.
4
Establish connection attributes for the TContext instance.
Execute connect() to specify the webMethods Integration Server on which you want to invoke services using this context.
You must connect as a user who is a member of the Administrators group on the Integration Server.
Note:
Multiple threads can share an instance of TContext as long as they use the same connection attributes—i.e., they use the same webMethods Integration Server and user ID/password (i.e., Administrator/manage) established by that instance of TContext.
To set other connection attributes, use methods in the class Context such as the protocol to use (HTTP or HTTPS) and the proxy to use.
5
Start the transaction.
Execute startTx() to obtain a transaction ID (tid) and specify the transaction time-to-live (TTL).
6
Invoke the service.
Execute invokeTX() to invoke a service.
Note that you pass the transaction ID (tid) as the first parameter to this method.
7
End the transaction.
Execute endTx() to end the transaction. This method clears the record for this transaction from the Job Manager's job store.
8
Check for errors.
Check for the different types of errors. Always check for Service Exceptions last.
9
Close the session on webMethods Integration Server.
Execute disconnect to end the use of this instance of TContext. The application should not perform this step until it is done because disconnect unregisters TContext with the Job Manager.
10
Shutdown.
The Job Manager ends.
Important:
Do not include this step if your client will run as a service on a webMethods Integration Server. This function is automatically performed by the server and must not be included in your code.
For additional information about TContext and its methods, see the TContext class in the webMethods Integration Server Java API Reference.