/*
 * JORAM: Java(TM) Open Reliable Asynchronous Messaging
 * Copyright (C) 2004 - 2024 ScalAgent Distributed Technologies
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA.
 *
 * Initial developer(s): ScalAgent Distributed Technologies
 * Contributor(s): 
 */
package org.objectweb.joram.mom.dest;

import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;

public interface QueueMBean extends DestinationMBean {
  /**
   * Returns  the threshold value of this queue, -1 if not set.
   *
   * @return the threshold value of this queue; -1 if not set.
   */
  int getThreshold();

  /**
   * Sets or unsets the threshold for this queue.
   *
   * @param threshold The threshold value to be set or -1 for unsetting
   *                  previous value.
   */
  void setThreshold(int threshold);

  /**
   * Returns the number of waiting requests in the queue.
   *
   * @return The number of waiting requests.
   */
  int getWaitingRequestCount();

   /**
    * Removes all request that the expiration time is expired.
   * @throws Exception 
    */
   void cleanWaitingRequest() throws Exception;

  /**
   * Returns the number of pending messages in the queue.
   *
   * @return The number of pending messages.
   */
  int getPendingMessageCount();
  
  /**
   * Returns the number of messages waiting for a delay.
   *
   * @return The number of messages waiting for a delay.
   */
  int getDelayedMessageCount();
 
//  /**
//   * Returns the load averages for the last minute.
//   * @return the load averages for the last minute.
//   */
//  float getAverageLoad1();
//
//  /**
//   * Returns the load averages for the past 5 minutes.
//   * @return the load averages for the past 5 minutes.
//   */
//  float getAverageLoad5();
//  
//  /**
//   * Returns the load averages for the past 15 minutes.
//   * @return the load averages for the past 15 minutes.
//   */
//  float getAverageLoad15();
  
  /**
   * Return the average producer's load during last moments.
   */
  public long getProducerLoad();
  
  /**
   * Return the average consumer's load during last moments.
   */
  public long getConsumerLoad();
    
   /**
    * Removes all messages that the time-to-live is expired.
    */
   void cleanPendingMessage() throws Exception;

  /**
   * Returns the number of messages delivered and waiting for acknowledge.
   *
   * @return The number of messages delivered.
   */
  int getDeliveredMessageCount();
  
  /**
   * Returns the number of messages denied since creation time of this
   * destination.
   *
   * @return the number of messages delivered since creation time.
   */
  long getNbMsgsDeniedSinceCreation();

  /**
   * Returns the maximum number of message for the destination.
   * If the limit is unset the method returns -1.
   *
   * @return the maximum number of message for subscription if set;
   *	     -1 otherwise.
   */
  int getNbMaxMsg();

  /**
   * Sets the maximum number of message for the destination.
   *
   * @param nbMaxMsg the maximum number of message (-1 set no limit).
   */
  void setNbMaxMsg(int nbMaxMsg);

  /**
   * Returns the description of a particular pending message. 
   * The message is pointed out through its unique identifier.
   * 
   * @param msgId The unique message's identifier.
   * @return the description of the message.
   * 
   * @see org.objectweb.joram.mom.messages.MessageJMXWrapper
   */
  public CompositeData getMessage(String msgId) throws Exception;

  /**
   * Returns the description of all pending messages.
   * 
   * @return the description of the message.
   * 
   * @see org.objectweb.joram.mom.messages.MessageJMXWrapper
   */
  public TabularData getMessages() throws Exception;

  /**
   * Returns the description of a particular delayed message. 
   * The message is pointed out through its unique identifier.
   * 
   * @param msgId The unique message's identifier.
   * @return the description of the message.
   * 
   * @see org.objectweb.joram.mom.messages.MessageJMXWrapper
   */
  public CompositeData getDelayedMessage(String msgId) throws Exception;

  /**
   * Returns the description of all delayed messages.
   * 
   * @return the description of the message.
   * 
   * @see org.objectweb.joram.mom.messages.MessageJMXWrapper
   */
  public TabularData getDelayedMessages() throws Exception;

// No longer needed (JORAM-304).

//  public List getMessagesView();
//  public CompositeData[] getMessages() throws Exception;
  
  /**
   * Return the reDeliveryDelay (unit: second)
   */
  int getRedeliveryDelay();

  /**
   * @param reDeliveryDelay the reDeliveryDelay to set(unit: second)
   */
  void setRedeliveryDelay(int reDeliveryDelay);
  
  /**
   * Returns the Queue deliveryDelay in milliseconds.
   * @return the DeliveryDelay
   */
  int getDeliveryDelay();
  
  /**
   * Sets the Queue deliveryDelay in milliseconds.
   * @param deliveryDelay the deliveryDelay to set
   */
  void setDeliveryDelay(int deliveryDelay);
  
  boolean isPause();
  void setPause(boolean pause);
  
  /**
   * Exports all messages in the specified directory.
   * Options? filtrage? Format?
   */
  void exportMessages(String dirpath, String selector, boolean quiet) throws Exception;
  
  /**
   * Removes all pending messages.
   */
  public void clear();
}
