title: Browse, read, and remove a message from a queue using IBM MQ classes
body: <p>I'm writing a simple Java application using MQ classes for Java with Eclipse.</p>
  
  <p>Right now I'm able to browse a remote queue without removing the messages stored.<br>
  Here is the code of the reading cycle:</p>
  
  <pre><code>MQQueueManager QMgr = new MQQueueManager(qManager); //&lt;-- qManager is a String with the QMgr name
  
  int openOptions = MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_INPUT_SHARED | MQC.MQOO_BROWSE;  
  
  MQQueue queue = QMgr.accessQueue(queueName, openOptions);
  
  MQMessage theMessage    = new MQMessage();
  MQGetMessageOptions gmo = new MQGetMessageOptions();
      gmo.options=MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_FIRST;
      gmo.matchOptions=MQC.MQMO_NONE;
      gmo.waitInterval=5000;
  
  boolean thereAreMessages=true;
  while(thereAreMessages){
      try{
          //read the message          
          queue.get(theMessage,gmo);  
          //print the text            
          String msgText = theMessage.readString(theMessage.getMessageLength());
          System.out.println("msg text: "+msgText);
  
                   // &lt;--- Solution code Here
  
          //move cursor to the next message               
          gmo.options = MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_NEXT;
  
      }catch(MQException e){
  
          if(e.reasonCode == e.MQRC_NO_MSG_AVAILABLE) {
              System.out.println("no more message available or retrived");
          }
  
          thereAreMessages=false;
      } catch (IOException e) {
          System.out.println("ERROR: "+e.getMessage());
      }
  }
  </code></pre>
  
  <p><strong>Main question:</strong>
  After the read message line and before moving the cursor to the next message how can I remove the message from the queue?</p>
  
  <p><strong>Secondary question:</strong>
  Eclispe is warning me that all the costants used for the options are deprecated; which are the correct ones to use?</p>
  
  <hr>
  
  <p><strong>Solution:</strong></p>
  
  <p>Here the solution I'm really looking for:</p>
  
  <pre><code>// set te cursor to remove the message from the queue
  gmo.options = CMQC.MQGMO_MSG_UNDER_CURSOR;
  queue.get(theMessage, gmo);
  </code></pre>
  
  <p>these lines have to be inserted in the question code</p>
  
  <p>I've found it here: <a href="http://www.velocityreviews.com/forums/t124676-mq-series-messages-browse-and-delete.html" rel="nofollow noreferrer">http://www.velocityreviews.com/forums/t124676-mq-series-messages-browse-and-delete.html</a></p>