closing MQ connection

Posted by OakvilleWork on Stack Overflow See other posts from Stack Overflow or by OakvilleWork
Published on 2010-12-30T21:38:03Z Indexed on 2010/12/30 21:53 UTC
Read the original article Hit count: 266

Filed under:
|
|

Good afternoon, I wrote a project to Get Park Queue Info from the IBM MQ, it has producing an error when attempting to close the connection though. It is written in java. Under application in Event Viewer on the MQ machine it displays two errors. They are:

“Channel program ended abnormally. Channel program ‘system.def.surconn’ ended abnormally. Look at previous error messages for channel program ‘system.def.surconn’ in the error files to determine the cause of the failure.

The other message states: “Error on receive from host rnanaj (10.10.12.34) An error occurred receiving data from rnanaj (10.10.12.34) over tcp/ip. This may be due to a communications failure. The return code from tcp/ip recv() call was 10054 (X’2746’). Record these values.”

This must be something how I try to connect or close the connection, below I have my code to connect and close, any ideas??

Connect:

_logger.info("Start");

        File outputFile = new File(System.getProperty("PROJECT_HOME"), "run/" + this.getClass().getSimpleName() + "." + System.getProperty("qmgr") + ".txt");
        FileUtils.mkdirs(outputFile.getParentFile());

        Connection jmsConn = null;
        Session jmsSession = null;
        QueueBrowser queueBrowser = null;
        BufferedWriter commandsBw = null;
        try {
            // get queue connection
            MQConnectionFactory MQConn = new MQConnectionFactory();
            MQConn.setHostName(System.getProperty("host"));
            MQConn.setPort(Integer.valueOf(System.getProperty("port")));
            MQConn.setQueueManager(System.getProperty("qmgr"));
            MQConn.setChannel("SYSTEM.DEF.SVRCONN");
            MQConn.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);

            jmsConn = (Connection) MQConn.createConnection();
            jmsSession = jmsConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
            Queue jmsQueue = jmsSession.createQueue("PARK");

            // browse thru messages
            queueBrowser = jmsSession.createBrowser(jmsQueue);
            Enumeration msgEnum = queueBrowser.getEnumeration();

            commandsBw = new BufferedWriter(new FileWriter(outputFile));
            //
            String line = "DateTime\tMsgID\tOrigMsgID\tCorrelationID\tComputerName\tSubsystem\tDispatcherName\tProcessor\tJobID\tErrorMsg";
            commandsBw.write(line);
            commandsBw.newLine();

            while (msgEnum.hasMoreElements()) {
                Message message = (Message) msgEnum.nextElement();
                line = dateFormatter.format(new Date(message.getJMSTimestamp()))
                        + "\t" + message.getJMSMessageID()
                        + "\t" + message.getStringProperty("pkd_orig_jms_msg_id")
                        + "\t" + message.getJMSCorrelationID()
                        + "\t" + message.getStringProperty("pkd_computer_name")
                        + "\t" + message.getStringProperty("pkd_subsystem")
                        + "\t" + message.getStringProperty("pkd_dispatcher_name")
                        + "\t" + message.getStringProperty("pkd_processor")
                        + "\t" + message.getStringProperty("pkd_job_id")
                        + "\t" + message.getStringProperty("pkd_sysex_msg");
                _logger.info(line);
                commandsBw.write(line);
                commandsBw.newLine();
            }

        }

Close:

finally {
            IO.close(commandsBw);
            if (queueBrowser != null) { try { queueBrowser.close();} catch (Exception ignore) {}}
            if (jmsSession != null) { try { jmsSession.close();} catch (Exception ignore) {}}
            if (jmsConn != null) { try { jmsConn.stop();} catch (Exception ignore) {}}
        }

© Stack Overflow or respective owner

Related posts about java

Related posts about websphere-mq