[z/OS]

将出站 API 与外部地址空间或子系统配合使用

使用本任务在出站 API 与外部地址空间或子系统之间创建交互。

开始之前

与外部地址空间或子系统建立连接,如“使用优化本地适配器从 WebSphere® Application Server on z/OS® 应用程序中调用外部地址空间或子系统”主题所述。

过程

  1. 可选: 如果要使用支持事务的客户信息控制系统 (CICS®) 服务器任务,请启动资源管理器局部事务 (RMLT)。 要使用支持事务的 CICS 服务器任务,那么启动该服务器任务时将使用关键字 TXN=Y。可启动 RMLT 以将若干交互封装到单个工作单元中。Java™ Enterprise Edition (Java EE) 应用程序组件不得在全局事务上运行,并且必须在其应用程序部署描述符中将 LocalTransaction 边界设置为 Application。以下示例显示更改部署描述符后如何使用 LocalTransaction 对象启动局部事务:
    LocalTransaction lt = con.getLocalTransaction();
    lt.begin();

    有关如何在应用程序部署描述符上更改 LocalTransaction 设置的更多信息,请参阅“配置事务部署属性”主题。

    如果 Java EE 应用程序组件配置为使用 LocalTransaction 边界 ContainerAtBoundary,那么获得连接时该连接会自动列示在 RMLT 中。使用该连接时完成的工作是 Java EE 应用程序组件结束时自动完成的。

    如果 Java EE 应用程序组件在全局事务中启动,那么获得连接时连接器会自动列示在全局事务中。使用该连接时完成的工作是 Java EE 应用程序组件结束时自动完成的。用于获取连接的 ConnectionFactory 对象已设置 RegisterName 定制属性以参与全局事务。

  2. 使用连接对象来创建交互,例如:
    Interaction int = con.createInteraction();
  3. 创建 InteractionSpecImpl 对象,并在交互规范中设置服务名称。 服务名称描述要在远程系统上调用的方法或函数的名称。此服务名称 是在远程系统调用主机或其中一个接收请求 API 时提供的,或者,在使用客户信息控制系统 (CICS) 服务器任务时,这是要在 CICS 中启动的程序名,例如:
    InteractionSpecImpl isi = new InteractionSpecImpl();
    isi.setServiceName("MYSERVICE");
    注意: 使用基于 OTMA 的优化本地适配器时,未定义服务名称,并且在消息流中指定了目标 IMS™ 事务。可设置服务名称,但它不会用于基于 OTMA 的优化本地适配器。有关更多信息,请参阅“使用基于 OTMA 的优化本地适配器调用现有 IMS 事务”主题。
  4. 使用创建的交互规范来运行交互,例如:
    int.execute(isi, null);
  5. 如果应用程序使用了 RMLT,那么完成最后一次交互后,请落实或退出工作。 对 LocalTransaction 对象使用落实或回滚方法,例如:
    lt.commit();

结果

与该外部地址空间或子系统的交互已完成。
注意: 使用 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;
		 }

指示主题类型的图标 任务主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tdat_useoutboundconnection
文件名:tdat_useoutboundconnection.html