![[z/OS]](../images/ngzos.gif)
将出站 API 与外部地址空间或子系统配合使用
使用本任务在出站 API 与外部地址空间或子系统之间创建交互。
开始之前
过程
结果
注意: 使用 RMLT 或全局事务时,如果 CICS
应用程序在 RMLT 或全局事务期间发出同步点,那么服务器任务会在同步点期间发出 BBOX 异常中止。这会导致同步点失败,并且
CICS 会生成 ASPx 异常中止。CICS
应用程序应等待 WebSphere Application
Server 通过对 LocalTransaction 对象调用落实或回滚方法发出同步点操作,或让 Java EE
应用程序组件完成工作。
注意: 如果要定义在将全局事务上下文或 RMLT 从 WebSphere 中导入到
CICS 中时可运行 CICS 事务的最短时间,请修改用于启动
CICS 链路服务器链路任务的事务定义上的
OTSTIMEOUT 参数值。缺省情况下,事务名称为 BBO#。如果
CICS 事务运行时超过 OTSTIMEOUT
参数指定的时间,那么运行 CICS 事务的
CICS 任务异常中止,导致整个全局事务或 RMLT 回滚。有关如何在事务定义上编写 OTSTIMEOUT
参数的信息,请参阅 CICS Transaction Server
for z/OS Resource Definition
Guide。
如果 Java EE 应用程序组件要参与 RMLT 或全局事务,并且应用程序要与批处理程序或 CICS 链路服务器(启动时指定了关键字 TXN=N)通信,那么优化本地适配器无法建立与目标程序的连接。目标程序无法提供 Java EE 应用程序所需的事务功能。将显示一个异常,该异常带有次代码 0xC9C24C3B。此代码指示发现目标注册名称,但未对事务启用该目标注册。只有 CICS 链路服务器(启用时指定了关键字 TXN=Y)可支持通过 WebSphere Application Server for z/OS 传播事务。
示例
以下方法显示如何启动与字节数组 (byte[]) 形式的输入和输出数据的交互:
public byte[] driveInteraction(javax.resource.cci.ConnectionFactory cf,
javax.resource.cci.Connection con,byte[] inputDataBytes),throws javax.resource.ResourceException
{
// Create an interaction using the optimized local adapter connection
javax.resource.cci.Interaction i = con.createInteraction();
// The InteractionSpec describes the service we want to call
com.ibm.websphere.ola.InteractionSpecImpl isi = new com.ibm.websphere.ola.InteractionSpecImpl();
isi.setServiceName("MYSERVICE");
// The input data is specified using an IndexedRecord. The first
// slot in the indexed record contains the input data bytes.
javax.resource.cci.RecordFactory rf = cf.getRecordFactory();
javax.resource.cci.IndexedRecord ir = rf.createIndexedRecord(null);
ir.add(inputDataBytes);
// The interaction returns another IndexedRecord, whose first
// slot contains the output data bytes.
javax.resource.cci.Record or = i.execute(isi, ir);
byte[] outputDataBytes = null;
if (or != null)
{
outputDataBytes = (byte[])((javax.resource.cci.IndexedRecord)or).get(0);
}
// Return the output data to the caller
return outputDataBytes;
}
以下方法说明如何使用 Rational® Application Developer 生成的副本 Record 对象来启动交互:
/**
* An example of driving an optimized local adapter interaction, using a Rational
* Application Developer copybook mapping class as input (inputRecord) and receiving
* a Rational Application Developer copybook mapping as output.
*/
public javax.resource.cci.Record driveInteraction(
javax.resource.cci.Connection con,
javax.resource.cci.Record inputRecord)
throws javax.resource.ResourceException
{
// Create an interaction using the OLA connection
javax.resource.cci.Interaction i = con.createInteraction();
// The InteractionSpec describes the service we want to call com.ibm.websphere.ola.InteractionSpecImpl isi =
new com.ibm.websphere.ola.InteractionSpecImpl();
isi.setServiceName("MYSERVICE");
// The Rational Application Developer generated copybook implements
// javax.resource.cci.Record and can be passed directly to the interaction.
// The interaction returns an IndexedRecord, whose first slot contains
// the output data bytes.
javax.resource.cci.Record or = i.execute(isi, inputRecord);
javax.resource.cci.Record outputRecord = null;
if (or != null)
{
// In this example, RADGeneratedOutputType is the name of the Rational Application Developer
// generated copybook mapping class.
outputRecord = new RADGeneratedOutputType();
// The output bytes are stored in the output record returned on the
// interaction, which is an IndexedRecord.
byte[] outputDataBytes =
(byte[])((javax.resource.cci.IndexedRecord)or).get(0);
// To convert the output bytes to another Rational Application Developer generated copybook,
// call the setBytes(byte[]) method of that class. The class will
// implement the com.ibm.etools.marshall.RecordBytes interface.
((com.ibm.etools.marshall.RecordBytes)outputRecord)
.setBytes(outputDataBytes);
}
// Return the output data to the caller
return outputRecord;
}