Example usage for javax.resource.cci Connection createInteraction

List of usage examples for javax.resource.cci Connection createInteraction

Introduction

In this page you can find the example usage for javax.resource.cci Connection createInteraction.

Prototype

public Interaction createInteraction() throws ResourceException;

Source Link

Document

Creates an Interaction associated with this Connection.

Usage

From source file:org.mule.transport.cics.CtgAdapter.java

/**
 * This method actually calls JCA and CTG APIs.
 * //from  w ww .  j  a  va  2s .c om
 * @param <code>Connection</code> mainframe connection 
 * @param inRec a request record
 * @return a reply record from mainframe
 * @throws Exception
 *             if an error occured
 */
private CicsRecord execute(Connection con, CicsRecord inRec) throws Exception {
    try {
        CicsRecord outRec = new CicsRecord(); // reply record

        // execute a mainframe transaction
        logger.debug("CICS-ACCESS start...inRec:[" + inRec + "]");
        con.createInteraction().execute(this.ixnSpec, inRec, outRec);
        logger.debug("CICS-ACCESS end....outRec:[" + outRec + "]");

        return outRec;

    } catch (com.ibm.connector2.cics.CICSTxnAbendException re) {

        String msg = "Error - CICS Abend: "; // CICS abend
        if (re.getErrorCode() != null) {
            msg += ": " + re.getErrorCode();
        }
        if (re.getErrorCode().equals("AEIO")) {
            msg += " Msg: CICS Program not found";
        } else {
            msg += " Msg: Check CICS log";
        }
        throw new Exception("CICS_ABEND_ERR: " + msg, re);

    } catch (javax.resource.spi.SecurityException re) {

        // if a security violation occurs
        String msg = "Error - Security";
        if (re.getErrorCode() != null)
            msg += ": " + re.getErrorCode();
        int errCode = Integer.parseInt(re.getErrorCode());
        if (errCode == ECIResourceAdapterRc.ECI_ERR_SECURITY_ERROR) {
            msg += " Msg: Check credentials for userid ";
        } else {
            msg += " Msg: " + re.getMessage();
        }

        throw new Exception("CICS_SECURITY_ERR:" + msg, re);

    } catch (javax.resource.spi.CommException re) {

        // if a communication error occurs
        String msg = "Error - CICS Communication";
        if (re.getErrorCode() != null)
            msg += ": " + re.getErrorCode();
        if (re.getCause() != null) {
            if (re.getCause() instanceof java.io.IOException) {
                msg += " Msg: IO error: check gateway daemon";
            } else {
                msg += "Linked exception = " + re.getCause();
            }
        }

        if (re.getErrorCode() != null) {
            int errCode = Integer.parseInt(re.getErrorCode());
            if (errCode == ECIResourceAdapterRc.ECI_ERR_NO_CICS) {
                msg += " Msg: CICS server is stopped";
            } else {
                msg += " Msg: " + re.getMessage();
            }
        }
        throw new Exception("CICS_COMMUNICATION_ERR:" + msg, re);

    } catch (javax.resource.spi.ResourceAllocationException re) {

        // A communication error occured between CTG and CICS.
        // If CICS on mainframe is not running, this error occurs.
        String msg = "Error - Resource allocation";
        if (re.getErrorCode() != null)
            msg += ": " + re.getErrorCode();
        int errCode = Integer.parseInt(re.getErrorCode());
        if (errCode == ECIResourceAdapterRc.ECI_ERR_RESOURCE_SHORTAGE) {
            msg += " Msg: Check network from CTG to CICS";
        } else {
            msg += " Msg: " + re.getMessage();
        }
        throw new Exception("CICS_CTG_ERR:" + msg, re);

    } catch (javax.resource.spi.EISSystemException re) {

        String msg = "Error - CICS System error";
        if (re.getErrorCode() != null)
            msg += ": " + re.getErrorCode();
        msg += "Msg: " + re.getMessage();
        throw new Exception("CICS_EIS_ERR", re);
    } catch (Exception re) {
        // if other exception occurs
        throw new Exception("CICS_ERR", re);
    }
}

From source file:org.mule.transport.cicsStreaming.CtgAdapter.java

/**
 * This method actually calls JCA and CTG APIs.
 * /*from ww  w .  j a v  a  2  s.  c  om*/
 * @param <code>Connection</code> mainframe connection 
 * @param inRec  a request record
 * @param outRec a response record
 * @return       a reply record from mainframe
 * @throws Exception if an error occured
 */
private void execute(Connection con, Record inRec, Record outRec) throws Exception {
    try {
        // execute a mainframe transaction
        logger.debug("CICS-ACCESS start...");
        con.createInteraction().execute(this.ixnSpec, inRec, outRec);
        logger.debug("CICS-ACCESS end....");

    } catch (com.ibm.connector2.cics.CICSTxnAbendException re) {

        String msg = null; // CICS abend
        String errorCode = re.getErrorCode();
        if (errorCode == null) {
            msg = "Check CICS log.";
        } else if ("AEIO".equals(errorCode)) {
            msg = errorCode + " CICS Program not found.";
        } else {
            msg = errorCode + " Check CICS log.";
        }
        CicsMessages messages = new CicsMessages();
        throw new Exception(messages.cicsAbendError(msg).toString(), re);

    } catch (javax.resource.spi.SecurityException re) {
        // if a security violation occurs
        String msg = null;
        String errorCode = re.getErrorCode();
        if (errorCode == null) {
            msg = re.getMessage();
        } else {
            int errCode = parseInt(errorCode);
            if (errCode == ECIResourceAdapterRc.ECI_ERR_SECURITY_ERROR) {
                msg = errorCode + " Check credentials for userid.";
            } else {
                msg = errorCode + " " + re.getMessage();
            }
        }
        CicsMessages messages = new CicsMessages();
        throw new Exception(messages.cicsSecurityError(msg).toString(), re);

    } catch (javax.resource.spi.CommException re) {
        // if a communication error occurs
        String msg = null;
        String errorCode = re.getErrorCode();
        if (errorCode == null) {
            msg = re.getMessage();
        } else {
            int errCode = parseInt(errorCode);
            if (errCode == ECIResourceAdapterRc.ECI_ERR_NO_CICS) {
                msg = errorCode + " CICS server is stopped.";
            } else {
                msg = errorCode + " " + re.getMessage();
            }
        }

        if (re.getCause() != null) {
            if (re.getCause() instanceof java.io.IOException) {
                msg = " IO error: check gateway daemon.";
            } else {
                msg = " Linked exception: " + re.getCause();
            }
        }
        CicsMessages messages = new CicsMessages();
        throw new Exception(messages.cicsCommunicationError(msg).toString(), re);

    } catch (javax.resource.spi.ResourceAllocationException re) {
        // A communication error occured between CTG and CICS.
        // If CICS on mainframe is not running, this error occurs.
        String msg = null;
        String errorCode = re.getErrorCode();
        if (errorCode == null) {
            msg = re.getMessage();
        } else {
            int errCode = parseInt(errorCode);
            if (errCode == ECIResourceAdapterRc.ECI_ERR_RESOURCE_SHORTAGE) {
                msg = errorCode + " Check network from CTG to CICS";
            } else {
                msg = errorCode + " " + re.getMessage();
            }
        }
        CicsMessages messages = new CicsMessages();
        throw new Exception(messages.cicsCTGError(msg).toString(), re);
    } catch (javax.resource.spi.EISSystemException re) {
        String msg = null;
        String errorCode = re.getErrorCode();
        if (errorCode != null)
            msg = errorCode + ": ";
        msg += re.getMessage();
        CicsMessages messages = new CicsMessages();
        throw new Exception(messages.cicsEISError(msg).toString(), re);

    } catch (Exception re) {
        // if other exception occurs
        throw new Exception("CICS_ERR", re);
    }
}