Resource Recovery Services (RRS) provide the sync point services component of the z/OS Recoverable Resource Manager Services (RRMS). These sync point services implement two-phase commit across resource managers within z/OS, letting applications have a single recovery point for various data sources without requiring a transaction manager such as CICS. DB2 can participate as one of these resource managers; it provides an Application Programming Interface (API) to connect with programs that want to take advantage of RRS. Programs that use the RRS Attachment Facility (RRSAF) to connect to DB2 can use embedded SQL, issue DB2 commands, and use the Instrumentation Facility Interface (IFI) to collect performance information. Programs that run in stored procedure address spaces managed by Workload Manager (WLM) are required to use RRSAF, but may not issue RRSAF API calls.
So, why would you want to start using this when your current programs work fine without it? The answer lies in the flexibility of using RRSAF and the future of your development environments. Many programmers coming out of school have little or no experience with z/OS, don’t know what TSO is, and probably don’t even know COBOL. On the other hand, they usually know how to work in a Unix shell environment and we do have that available with Unix System Services (USS). Programs that use RRSAF to manage their connection to DB2 can run in TSO, USS, and batch environments with no modification.
Java applications running under WebSphere should already be using RRSAF for their DB2 connections. When strange things happen to the connections from these applications, you may even see RRSAF error messages in the WebSphere logs. Using RRSAF for DB2 connections supports inclusion of other resource managers, such as WebSphere MQ and CICS, in the unit of work.
The step involved in using RRSAF for most programs is easily encapsulated in a simple program that can be reused to establish the connection for each application program. You can create a simple “OpenDB2” program each of our programs calls to establish the connection; it issues the calls to program DSNRLI, which is the high-level interface program for RRSAF.
You must supply some additional information to the OpenDB2 program. This includes the DB2 subsystem name and the plan name that will be used to find the packages the programs will use. It’s helpful to standardize programs to accept both the subsystem and plan names as input parameters. Additionally, you can specify the correlation ID that DB2 will use when reporting performance information on your application. This can be accepted as an input parameter or generated internally by the OpenDB2 program.
After the call to OpenDB2, you can use embedded SQL statements in your programs just as you would in programs that use the TSO attachment facility. If you use only DB2 resources, then you can even use the standard SQL commit and rollback statements to control your units of work. To control a unit of work that includes other resources, you need to use the SRRCMIT and SRRBACK APIs within RRS. Units of work that involve multiple resource managers are called global transactions. You can use these calls for DB2-only transactions as well, since DB2 supplies its own version of the programs.
Building your applications then becomes a matter of following the correct steps. You include the call to OpenDB2 in your program. For the DB2 precompiler, you specify ‘ATTACH(RRSAF)’ as an option. The DSNRLI module should also be included in a link step that builds the load module for your application program. If you use the SRRCMIT and SRRBACK calls for global transactions, then you need to include the RRS modules’ library (SYS1.CSSLIB) before the DB2 library in your link step to make sure you pick up the correct version.
When your program processing completes, the RRSAF connection will be terminated without any need for you to take specific action. You can close the connection explicitly, but this is not necessary. Normal termination will result in your work being committed, while abnormal termination will result in a rollback.
Running RRSAF Programs