É possível criar um encadeamento que inicie uma tarefa em CICS usando o CICSExecutorService. Se usar este serviço para criar um encadeamento, uma tarefa CICS será criada e poderá usar a API JCICS para acessar os serviços CICS.
Você tem duas opções para criar um encadeamento que inicie uma tarefa CICS. Se deseja que seu código seja portátil, é possível usar o ExecutorService na estrutura OSGi. Quando o aplicativo está em execução em um servidor JVM, a estrutura OSGi usa automaticamente a implementação CICS para iniciar uma tarefa CICS quando um encadeamento é criado. Se você estiver gravando um aplicativo especialmente para CICS, será possível usar a classe CICSExecutorService diretamente usando JCICS.
package com.ibm.cics.executor.test;
import com.ibm.cics.server.CICSExecutorService;
import com.ibm.cics.server.TSQ;
import com.ibm.cics.server.TSQType;
public class ExecutorTest
{
public static void main(String[] args)
{
// Inline the new Runnable class
class CICSJob implements Runnable
{
public void run()
{
// Create a temporary storage queue
TSQ test_tsq = new TSQ();
test_tsq.setType(TSQType.MAIN);
// Set the TSQ name
test_tsq.setName("TSQWRITE");
// Write to the temporary storage queue
// Use the CICS region local CCSID so it is readable
String test_string = "Hello from a non CICS Thread - "+ threadId;
try
{
test_tsq.writeItem(test_string.getBytes(System.getProperty("com.ibm.cics.jvmserver.local.ccsid")));
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
// Create and run the new CICSJob Runnable
Runnable task = new CICSJob();
CICSExecutorService.runAsCICS(task);
}
}