CICS系统是IBM大型机上的重要的交易处理系统,并且由于大型机的特殊性,导致CICS的已有应用程序对分布式平台开放不够,难以重用以往的应用程序。因此,CICS与分布式系统的交互,即外界如何访问CICS传统应用,成为一个重要的课题。
而CTG(CICS Transaction gateway,以下简称为CTG),CICS交易网关,是分布式平台连接到CICS的首选工具,它具有高性能,高安全性,高可扩展性等特性。
CTG与CICS的连接属于直接相连的方式,几乎不用修改CICS的已有应用,即可被外界访问。Web Services 同样可以实现与CICS的连接,但是相比于Web Services,CTG有以下优势:
相关概念介绍:
1. Gateway Daemon (网关守护程序):网关守护程序用于监听远端客户程序的请求,并且可以管理线程和网络连接,以达到优化的目的。网关守护程序中的一个重要组件是协议处理器(Protocol Handler),用于处理远端应用程序的请求,可以支持TCP/IP和SSL协议。
2. Client Daemon (客户机守护程序):客户机守护程序是开放平台CTG的重要组成部分,它提供一个本地接口,客户应用程序就通过这个接口连接到CICS,支持C,C++,.Net,COBOL等多种语言的应用程序。
3. IPIC driver (IPIC 驱动器):IPIC驱动器是CTG中的一个独立组件,作用类似于客户机守护程序,专用于IPIC方式连接到CICS。CICS在3.2版本中引入了IPIC(IP Intercommunication)的概念,用于CICS region之间的互连,这种连接是基于TCP/IP协议的,具体的IPIC概念请参考其他相关章节。从CTG V7.1版本以后,加入了对IPIC的支持。
4. CTGCFG tool(CTG configuration tool,CTG配置工具):CTG产品自带的图形化配置工具,用于设置ctg.ini配置文件中的属性,包括网关守护程序和客户机守护程序等的相关参数。配置客户端守护程序界面,如下图所示:
![图像](https://dw1.s81c.com/developerworks/mydeveloperworks/blogs/cicschina/resource/BLOGS_UPLOADED_IMAGES/1402.jpg)
其中重要的几个参数描述如下:
(1) 服务器名称:一个8位长的字符串,定义一个独立于协议的服务器名称,客户端应用程序发到CICS的请求都要发到这个服务器。
(2) 协议:指定CTG所支持的各种网络协议,本章重点介绍TCP/IP协议。
(3) 主机名或IP地址:CICS所在的主机地址,可以指定主机名或IP地址。
(4) 端口:CICS端定义的TCPIPService所指定的端口,是客户端请求发送到CICS的接入点。
配置客户端守护程序界面,如下图所示:
![图像](https://dw1.s81c.com/developerworks/mydeveloperworks/blogs/cicschina/resource/BLOGS_UPLOADED_IMAGES/1403.jpg)
选中“启用协议处理程序”就能使图示的网关守护程序生效。
其中重要的几个参数描述如下:
(1)绑定地址:如果在此处指定某IP或主机名,就可以将协议处理程序绑定到上面指定的值;如果需要将协议处理程序绑定到任意地址,可以把此处留空不填。
(2)端口:安装CTG的服务器对外开放的CTG端口,默认为2006。
1.1.3 CTG编程接口
由于分布式系统架构的多样性,CTG支持一下三种连接方式:
1. External Call Interface (ECI) 外部访问接口
ECI是简单的RPC式访问接口,用来调用(LINK) CICS中的应用程序,可以使用COMMAREA或channel作为数据接口,用于客户应用程序和CICS之间的数据交换。
CICS将此种类型的访问看成是一种分布式程序调用(DPL : distributed program link )。客户端发来的请求由一个镜像交易CPMI进行处理,然后进一步调用到目标应用程序。
![图像](https://dw1.s81c.com/developerworks/mydeveloperworks/blogs/cicschina/resource/BLOGS_UPLOADED_IMAGES/1404.jpg)
2. External Presentation Interface (EPI) 外部表现接口
EPI被用来调用基于3270终端的交易。使用这种接口时,CICS上面会自动安装一个虚拟的终端,此终端受CTG的控制,并且CICS将客户端发来的请求运行在这个虚拟终端上。这种接口只支持SNA协议。
3. External Security Interface (ESI) 外部安全接口
ESI是用来验证并且修改CICS外部安全管理器(例如RACF)所保存的安全信息,并且由于CICS支持方面的原因,目前只能通过SNA协议进行连接。
![图像](https://dw1.s81c.com/developerworks/mydeveloperworks/blogs/cicschina/resource/BLOGS_UPLOADED_IMAGES/1406.jpg)
1.1.4 CTG支持的网络协议
TCP/IP:配置最简单的方式。
SNA:必须和Communication Server搭配使用。
IPIC:CICS在3.2版本中引入了IPIC(IP Intercommunication)的概念,用于CICS region之间的互连,这种连接是基于TCP/IP协议的,具体的IPIC概念请参考其他相关章节。从CTG V7.1版本以后,加入了对IPIC的支持。
Namedpipe:命名管道,只支持Windows版本的CTG。
EXCI:只支持Z/OS版本的CTG。
1.1.5 CTG的一些注意事项
1.CTG不支持从CICS端主动发出的访问请求。这里有个问题比较容易引起误解,就是CTG发送请求到CICS,CICS的返回信息可以正常返回给CTG,这种不是CICS主动发起的请求。
2.CTG不会做数据的转换,这个工作需要在应用程序或CICS中处理。
1.2 两种模式
CTG的有两种运行模式,这两种模式是根据CTG以及客户应用的拓扑结构来区分的。具体是哪种模式取决于客户应用程序的部署位置,分别为本地模式和远程模式。
1.本地模式(Local Mode,两层结构)
![图像](https://dw1.s81c.com/developerworks/mydeveloperworks/blogs/cicschina/resource/BLOGS_UPLOADED_IMAGES/1407.jpg)
在本地模式下,客户应用程序与安装CTG的server为同一台机器。在客户应用程序对CICS发送请求的时候,不需要经过网关守护程序,而是直接发送到CICS端,因此,整个体系架构可以看作两层的结构。这种模式下,根本无需启动网关守护程序,对CICS的请求直接发送到客户端守护程序。
在客户应用程序中的ECI请求中仍需要指定URL参数为local,即ConnectionURL = "local://" 和PortNumber = 0。
2. 远程模式(Remote Mode,三层结构)
![图像](https://dw1.s81c.com/developerworks/mydeveloperworks/blogs/cicschina/resource/BLOGS_UPLOADED_IMAGES/1408.jpg)
在远程模式下,客户应用程序与安装CTG的server为不同的机器,甚至不同的系统平台。在这种模式下,必须要配置并且启动网关守护程序,网关守护程序介于客户应用程序和CICS之间,整体构成三层的结构。
在客户应用程序的ECI请求中需要指定URL参数为CTG所在机器的IP地址,即ConnectionURL = "XXX.XXX.XXX.XXX" 和PortNumber = XXX。
从另外一个角度对两种模式的诠释,见下图:
![图像](https://dw1.s81c.com/developerworks/mydeveloperworks/blogs/cicschina/resource/BLOGS_UPLOADED_IMAGES/1409.jpg)
图像 1.3 CTG连接到CICS实例
1.配置CICS region
1. Set the SIT parameter TCPIP=YES.
2. Install the following:
– CICS-supplied transient data queue CIEO, in group DFHDCTG
– Transaction CIEP in group DFHIPECI
– Program DFHIEP in group DFHIPECI
3. Add a TCP/IP listener to CICS. Use the following CEDA command to define a TCPIPSERVICE in a group:
– CEDA DEF TCPIPSERVICE(service-name) GROUP(group-name)
4. Use the following command to install the TCPIPSERVICE definition:
– CEDA INS TCPIPSERVICE(service-name) GROUP(group-name)
Attribute | Description |
POrtnumber | The port on which the TCP/IP service listens. |
PRotocol | The protocol of the service is ECI. |
TRansaction | The transaction that CICS runs to handle incoming ECI requests. Set it to CIEP. |
Backlog | The number of TCP/IP requests that are queued before TCP/IP starts to reject incoming requests. |
Ipaddress | The IP address (in dotted decimal form) on which the TCPIPSERVICE listens. For configurations with more than one IP stack, specify ANY to make the TCPIPSERVICE listen on all addresses. |
SOcketclose | Whether CICS should wait before closing the socket after issuing a receive for incoming data on that socket. NO is recommended for ECI connections, to ensure that the connection from the Client daemon always remains open. |
ATtachsec | Specifies the level of attach-time security required for TCP/IP connections. |
2.配置CTG
3.测试连接
1.4 应用程序开发
CTG提供多种编程接口,包括:
(1) J2EE Connector Architecture(JCA) JAVA API,即J2EE连接器架构JAVA应用程序接口,这是推荐的编程接口。
(2)基础的JAVA,C,COBOL,COM等编程接口。
1. Java 应用程序开发
![图像](https://dw1.s81c.com/developerworks/mydeveloperworks/blogs/cicschina/resource/BLOGS_UPLOADED_IMAGES/1412.jpg)
2. JCA 应用程序开发
JCA(J2EE Connector Architecture) defines a standard architecture for connecting the Java 2 Platform Enterprise Edition (J2EE) platform to heterogeneous Enterprise Information Systems (EIS). Examples of an EIS include transaction processing systems (such as the CICS TS) and Enterprise Resource Planning systems (such as SAP).
A resource adapter is a middle-tier between a Java application and an EIS, which enables the Java application to connect to the EIS. A resource adapter plugs into application servers supporting the JCA.
JNDI: The Java Naming and Directory Interface (JNDI) is part of the Java platform, providing applications based on Java technology with a unified interface to multiple naming and directory services.
J2C Connection Factory: The connection factory provides connections to the Enterprise Information System (EIS). It operates the connection management of JCA.
Common Client Interface (CCI) : The CCI defines a common API for interacting with resource adapters. It is independent of a specific EIS. A Java application interfaces with the resource adapter using this API.
System contracts: A set of system-level contracts between an application server and an EIS. These extend the application server to provide the following features: (Connection management, Transaction management, Security management). These system contracts are transparent to the application developer. That is, they do not implement these services themselves.
Resource adapter deployment and packaging: A resource adapter provider includes a set of Java interfaces/classes as part of the resource adapter implementation. These Java interfaces/classes are packaged together with a deployment descriptor to create a Resource Adapter Archive (represented by a file with an extension of rar). This Resource Adapter Archive is used to deploy the resource adapter into the application server.
![图像](https://dw1.s81c.com/developerworks/mydeveloperworks/blogs/cicschina/resource/BLOGS_UPLOADED_IMAGES/1413.jpg)
1. Look up a ConnectionFactory for the ECI resource adapter.
2. Create a Connection object using this ConnectionFactory. A Connection is a handle to the underlying network connection to the EIS. Specific connection properties, such as a user name and password, can be passed using an ECIConnectionSpec object.
3. Create an Interaction from the Connection. Specific interaction properties such as the transaction identifier can be passed using an ECIInteractionSpec object. The call to the EIS is initiated by invoking the execute() method on the interaction, passing data as input and output records.
4. After the required interactions have been processed, the interaction and connection should be closed.
1.5 应用举例
1.5.1 简单Java应用
public class CTGdemo {
... Java code ...
// Program name
String strProgram = "EC01";
// Port number
int iPort = 2006;
/*
* Use the extended constructor to set the parameters on the
* ECIRequest object
*/
eciRequestObject =
new ECIRequest(ECIRequest.ECI_SYNC, //ECI call type
strChosenServer, //CICS server
null, //CICS userid
null, //CICS password
strProgram, //CICS program to be run
null, //CICS transid to be run
abytCommarea, //Byte array containing the
// COMMAREA
iCommareaSize, //COMMAREA length
ECIRequest.ECI_NO_EXTEND, //ECI extend mode
0); //ECI LUW token
... Java code ...
}
... COBOL code ...
* Initialize commarea
MOVE SPACES TO DFHCOMMAREA.
* Invoke api to get system time
EXEC CICS
ASKTIME ABSTIME(WS-RAWTIME)
END-EXEC.
* Format
EXEC CICS
FORMATTIME ABSTIME(WS-RAWTIME)
DDMMYY(LK-DATE-OUT)
DATESEP('/')
TIME(LK-TIME-OUT)
TIMESEP(':')
END-EXEC.
... COBOL code ...
*end of program
1.5.2 JCA应用
Lab3 implements a simple internet banking.
Users can query/save/withdraw their money from the web application.
3. CICS Program – VSAM1
(1)three operations
(Query,Save,Withdraw)
(2) Operate the VSAM files
4. CICS DATA – VSAM files
(1)VSAM file1--USERINFO
(Username:10), (Account:6)
(Name:12), (Gender:6)
(2)VSAM file2--ACCOUNT
(Account:6), (Balance:10)
Comments (0)