Too many files open when using generic packager with external packager.xml file

微笑、不失礼 提交于 2019-12-11 18:32:16

问题


I am using jpos 2.1.0 where i am using external packager xml file for iso8583 client. Due to large number of request in two or three days, i encountered "Too Many Files Open" and i have set ulimit -n = 50000. I doubt that the packager files are not been closed properly due to which this limit has been exceeded. Please help me to close the open file properly.

    JposLogger logger = new JposLogger(isoLogLocation);
    org.jpos.iso.ISOPackager customPackager = new GenericPackager(isoPackagerLocation+iso8583Properties.getPackager());
    BaseChannel channel = new ASCIIChannel(iso8583Properties.getServerIp(), Integer.parseInt(iso8583Properties.getServerPort()), customPackager);
    logger.jposlogconfig(channel);

    try {
        channel.setTimeout(45000);
        channel.connect();
    }catch(Exception ex) {
        log4j.error(ex.getMessage());
        throw new ConnectIpsException("Unable to establish connection with bank.");
    }

    log4j.info("Connection established using ASCIIChannel");

    ISOMsg m = new ISOMsg();
    m.set(0, "1200");
            ........
    m.set(126, "connectIPS");

    m.setPackager(customPackager);
    log4j.info(ISOUtil.hexdump(m.pack()));
    channel.send(m);
    log4j.info("Message has been send");

    ISOMsg r = channel.receive();
    r.setPackager(customPackager);
    log4j.info(ISOUtil.hexdump(r.pack()));
    String actionCode = (String) r.getValue("39");

    channel.disconnect();
    return bancsxfr;
}

回答1:


You know when you open a file, a socket, or a channel, you need to close it, right?

I don't see a finally in your try that would close the channel.

You have a huge leak there.



来源:https://stackoverflow.com/questions/55867482/too-many-files-open-when-using-generic-packager-with-external-packager-xml-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!