public void sendMessage(String message) {

    try {
      mqSender.connect(configuration.getManagerName());
      mqSender.send(configuration.getQueueOutName(), message);
      mqSender.disconnect();
    } catch (MQException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public List<String> receiveMessage() {

    List<String> result = new ArrayList<String>();

    try {
      Util.info("Tentando se conectar a fila: " + configuration.getQueueInName());
      mqReceiver.connect(configuration.getManagerName());
      Util.info("Conectado a fila: " + configuration.getQueueInName());

      while (true) {
        String message = null;

        try {
          Util.info("Tentando receber uma mensagem");
          message = mqReceiver.receive(configuration.getQueueInName());
          result.add(message);

        } catch (MQException e) {
          if (e.getReason() == 2033) {
            mqReceiver.disconnect();
            return result;
          }
        }

        Util.info("Mensagem recebida: " + message);
      }

    } catch (MQException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        Util.info("Tentando desconectar da fila " + configuration.getQueueInName());
        mqReceiver.disconnect();
        Util.info("desconectado da fila " + configuration.getQueueInName());
      } catch (MQException e) {
        Util.severe("Nao foi possível desconectar da fila" + configuration.getQueueInName());
      }
    }
    return result;
  }
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == cancelB) {
     clearAndHide();
   } else if (e.getSource() == sendMessageB) {
     try {
       enviaMensaje();
       if (this.tBox.isQueue) this.tBox.setTableQueues();
       else {
         this.tBox.setTableMessages();
       }
     } catch (MQException e1) {
       tBox.console.setText("RC: " + e1.reasonCode + ". " + e1.getMessage());
     } catch (IOException e1) {
       tBox.console.setText(e1.getMessage());
     }
   } else if (e.getSource() == cancelMessPropertiesB) {
     clear();
   }
 }
  public static void main(String args[]) {
    try {
      MQEnvironment.hostname = "192.168.43.187";
      MQEnvironment.port = 1414;
      MQEnvironment.channel = "mymgrChannel";

      //            MQEnvironment.hostname = "10.10.10.93";
      //            MQEnvironment.port = 1415;
      //            MQEnvironment.channel = "ESBQManagerChannel";

      MQEnvironment.userID = "kirishanthy";
      MQEnvironment.password = "******";
      MQQueueManager qMgr = new MQQueueManager(qManager);
      int openOptions = MQConstants.MQOO_OUTPUT;
      MQQueue queue = qMgr.accessQueue(qName, openOptions);
      for (int i = 0; i < 1000; i++) {
        MQMessage msg = new MQMessage();
        //                String message = "this message from mymgr";
        String message = MQClientUtils.DEFAULT_PLACEORDER_PAYLOAD;
        msg.writeUTF(message);
        MQPutMessageOptions pmo = new MQPutMessageOptions();
        queue.put(msg, pmo);
      }
      queue.close();
      qMgr.disconnect();
    } catch (MQException ex) {
      ex.printStackTrace();
      System.out.println(
          "A WebSphere MQ Error occurred : Completion Code "
              + ex.completionCode
              + " Reason Code "
              + ex.reasonCode);

    } catch (java.io.IOException ex) {
      System.out.println("An IOException occurred whilst writing to the message buffer: " + ex);
    }
  }