7. 答案
(1)修改ECI v1示例源代碼,客戶端應用發送消息:”Hello, I am client!“,伺服器程序響應:”Receive: Hello, I am client! Response: Hello, I am server!“。
伺服器端,(9.119.154.229,只有TXSeries伺服器):
#cicsadd -c pd -r RGN1 HELO PathName=helloprg RSLKey=public
#cicsadd -c ld -r RGN1 LSN1 Protocol=TCP TCPService=test_43211
#vi /etc/services
添加:test_43211 43211/tcp
客戶端(CTG和客戶端應用程序):
#vi /etc/profile
添加:export CICSCLI=/opt/ibm/cicstg/bin/cicstg.ini
#. /etc/profile
#vi /opt/ibm/cicstg/bin/cicstg.ini
添加如下內容:
SECTION SERVER = RGN1
PROTOCOL=TCPIP
NETNAME=9.119.154.229
PORT=43211
ENDSECTION
#cicscli -s=RGN1
生成應用程序(請查看”/Unit 4/Exercise 1/“中的源代碼):
對於伺服器程序”helloprg“:
#cicstcl -lC -e -d helloprg.ccs
對於客戶端應用”client“:
#make -f client.mk
測試:
./client
如果一切正常,會出現下列消息(伺服器列表可能會不同):
CICS Transaction Gateway Basic ECI V1 Sample
Servers defined in the Client daemon:
1.PRD
2.IMAT
3.DB2
4.ORACLE
5.RGN1
Choose server to connect to:
5
Send Message:Hello, I am client!
Program HELO returned with data: Receive:Hello, I am client! Response:Hello, I am server!
(2)修改ECI v2示例源代碼, 客戶端應用發送消息:”Hello, I am client!“,伺服器程序響應:”Receive:Hello, I am client! Response:Hello, I am server!“。
伺服器端(9.119.154.229,TXSeries伺服器和CTG):
#cicsadd -c pd -r RGN1 HELO PathName=helloprg RSLKey=public
#cicsadd -c ld -r RGN1 LSN1 Protocol=TCP TCPService=test_43211
#vi /etc/services
添加:test_43211 43211/tcp
#vi /etc/profile
添加:export CICSCLI=/opt/ibm/cicstg/bin/cicstg.ini
#. /etc/profile
#vi /opt/ibm/cicstg/bin/cicstg.ini
向GATEWAY部分添加如下兩行:
protocol@tcp.handler=com.ibm.ctg.server.TCPHandler
protocol@tcp.parameters=connecttimeout=2000;idletimeout=600000;pingfrequency=60000;port=2006;bind
solinger=0;
#cicscli -s=RGN1
#ctgstart
客戶端(只有客戶端應用):
不需要配置。
生成應用程序(請查看”/Unit 4/Exercise 2/“中的源代碼):
對於伺服器程序”helloprg“:
#cicstcl -lC -e -d helloprg.ccs
對於客戶端應用”client“:
#make -f client.mk
測試:
./client
如果一切正常,會出現下列消息:
CICS Transaction Gateway Basic ECI V2 Sample
Usage: client [host name] [port number]
Connected to CICS TG on 9.119.154.229 using port 2006
Servers returned from CICS TG:
1. RGN1 –
Choose server to connect to, or q to quit:
1
An ECI_ERR_SECURITY_ERROR error occurred
Enter your CICS user ID:
a
Enter your CICS password or password phrase:
a
Program HELO returned with data: Receive:Hello, I am client! Response:Hello, I am server!
Closed connection to CICS Transaction Gateway
client completed successfully
TXSeries入門系列文章–單元五
交互通信
五單元 交互通信
關於本單元
region間通信指的是不同region之間互相通信——本地region可以訪問其他遠程region中的服務,或為遠程region提供本地服務。所以多個region可以共享CICS服務從而使得整個系統更有效率。在本單元中,將介紹DPL(Distributed program link) 和FS(Function Shipping)的配置和編程,也會介紹一個新的API“LINK“和”READ“的另一種用法。
1. Distributed program link
(1)什麼是DPL
“EXEC CICS LINK“命令允許一個程序鏈接到其他程序——當使用這條命令時,控制權會被傳遞給指定的第二個程序(被鏈接程序)。當第二個程序完成後,控制權會被交還給第一個程序(鏈接程序),並完成”EXEC CICS LINK“命令後的剩餘邏輯。
如果鏈接程序和被鏈接程序位於同一region,這就是普通的程序鏈接。通過擴展”EXEC CICS LINK“,被鏈接程序(後端程序)可以位於遠程region,這就是DPL。
此外,兩個程序可以通過COMMAREA傳遞數據。
DPL可以分離用戶介面和業務邏輯,並獲得性能收益,因為它更容易獲取資源,而且訪問資料庫的程序也可以分割成更小的程序以減少複雜度和調試時間。
(2)配置DPL
本節會給用戶一個簡單的示例配置,請遵循這些指令並根據實際環境進行配置。
在開始之前,請在兩個不同的機器上(或在同一機器上,但為了便於學習推薦前一種)創建兩個region,regionA作為本地region,regionB作為遠程region。
a. 向regionA添加鏈接程序的PD,TD
為了測試DPL, 需要為鏈接程序添加程序定義(PD)和交易定義(TD)。鏈接程序將向COMMAREA中放入數據,然後通過”EXEC CICS LINK“命令鏈接後端程序並通過COMMAREA獲得返回數據。下一節將介紹DPL編程的詳細信息。
b. 向regionA添加LD
監聽器定義(LD)指定被regionA監聽的埠號和regionA接收請求的地址。這個定義會在稍後被遠程region使用與本地region通信。
語法
cicsadd -c ld -r <regionA’s name> <LD entry name> Protocol=TCP TCPAddress=<regionA’s address> TCPService=”<TCP service name>”
選項
<regionA’s address>: 當regionB中的後端程序返回控制權時,這個地址會被用來與regionA通信。
<TCP Service name>: 在”/etc/services“文件中定義的服務名稱。
本步驟中不要忘記在”/etc/services“文件中定義TCP服務名稱和埠號。
參閱:
http://www-01.ibm.com/support/knowledgecenter/SSAL2T_8.1.0/com.ibm.cics.tx.doc/reference/r_listnr_defns.html?lang=en
c. 向regionA添加CD
通信定義(CD)描述與CICS region通信的其他region的配置,包括 CICS家族其他產品。每個CD描述一個遠程region。在本單元,CD會定義與regionB的通信。
語法
cicsadd -c cd -r <regionA’s name> <CD entry> ConnectionType=cics_tcp
RemoteLUName=”<regionB’s name>” RemoteTCPAddress=<regionB’s address>
RemoteTCPPort=<port listened by regionB> ListenerName=”<regionA’s LD entry name>”
選項
RemoteLUName: 如果連接類型是cics_tcp,RemoteLUName是遠程region的APPLID。在本示例中,會使用regionB的名稱。
RemoteTCPAddress: 遠程region所在機器的IP地址。
RemoteTCPPort: 遠程region監聽的埠號。
以下文章點擊率最高
Loading…