/** Closing all the connections one by one from the connection Map */
  public static void closeConnections() {
    StringBuffer strBuf = new StringBuffer();
    logger.warn("ATM Switch Interface Shutting Down....");

    try {
      ConcurrentHashMap<String, ServerContainer> ATMSWITCH_CONN_MAP =
          ConnectionPool.getConnectionMap();
      Set connSet = ATMSWITCH_CONN_MAP.keySet();
      Iterator It = connSet.iterator();

      while (It.hasNext()) {
        String connName = (String) (It.next());
        if (ConnectionPool.getHandleToContainer(connName) != null) {
          if (cleanUpResources(connName, false)) strBuf.append(connName + " is - Closed. ");
          else strBuf.append(connName + " could not be - Closed. ");
        }
      }
    } catch (Exception e) {
      logger.error(" closeConnections()  Exception ", e);
    }
    logger.info(strBuf.toString());
  }
  private String getResponse(String connId, String request, String nwMessageUID) throws Exception {
    Message msg = null;
    Message respMsg = null;
    ServerContainer containerHandle = ConnectionPool.getHandleToContainer(connId);
    MessageProcessor processMsg = null;
    try {
      if (containerHandle != null) {
        processMsg = containerHandle.getMessageProcessor();
      } else {
        if (!ATMSwitchTCPHandler.manualStopPool.get(connId)) {
          logger.warn(
              "( "
                  + connId
                  + " ,getResponse(,) ) No Processor found for this message. Tring to connect Again......");
          loadATMSwitchConfig(connId);
          containerHandle = ConnectionPool.getHandleToContainer(connId);
        }
        if (containerHandle != null) {
          processMsg = containerHandle.getMessageProcessor();
        } else {
          logger.error(
              "( "
                  + connId
                  + " ,getResponse(,) ), There is no Processor found for this message....");
          return null;
        }
      }
      MessageUID messageUID = new MessageUID();
      // Preparing a message Object to hold request and message unique id (here Message Unique Id is
      // STAN of the ISO request).
      if (!"".equalsIgnoreCase(nwMessageUID)) {
        String messageUIDStr = nwMessageUID;
        messageUID.setMaskedUID(messageUIDStr);
        messageUID.setUID(messageUIDStr);

      } else {
        ISOMsg res = new ISOMsg();
        res.setPackager(new ISO87APackager());
        res.unpack(request.getBytes());
        MessageUIDGenerator messageUIDGenerator = containerHandle.getMessageUIDGenerator();
        if (messageUIDGenerator != null) {
          messageUID = messageUIDGenerator.generateMessageUID(res);
        }
      }
      logger.info(
          "( "
              + connId
              + " ,getResponse(, ,) ) Request message UID : "
              + messageUID.getMaskedUID());
      msg = new Message(request, messageUID);

      Date startDate = new Date();

      // Sending Message
      processMsg.deliverMessageToThirdParty(containerHandle, msg);

      // Requesting for Response
      respMsg = processMsg.retrieveMessageFromThirdParty(containerHandle, msg);

      Date endDate = new Date();

      String respUID = (respMsg != null) ? respMsg.getMessageUID().getMaskedUID() : "NOTRCVD";
      if ("NOTRCVD".equals(respUID)) {
        logger.warn(
            "( "
                + connId
                + " ,getResponse(, ,) ) Round Robin Time [ "
                + ((endDate.getTime() - startDate.getTime()) / 1000)
                + " ] Req [ "
                + messageUID.getMaskedUID()
                + " ] Res [ NOTRCVD ]");
      } else {
        logger.info(
            "( "
                + connId
                + " ,getResponse(, ,) ) Round Robin Time [ "
                + ((endDate.getTime() - startDate.getTime()) / 1000)
                + " ] Req [ "
                + messageUID.getMaskedUID()
                + " ] Res [ "
                + respUID
                + " ]");
      }

    } catch (IOException e) {
      // Catching an IO exception and calling re-connect.
      logger.error(" ( " + connId + " ,getResponse(, ,) ) IOException ", e);
      // containerHandle.reConnect(connId);

    }
    if (respMsg == null) {
      return null;
    } else return respMsg.getMessageContents();
  }