Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.mq.server
Class BasicQueue

    java.lang.Object
      org.jboss.mq.server.BasicQueue

Direct Known Subclasses:
  ExclusiveQueue, PersistentQueue

public class BasicQueue
extends Object

This class represents a queue which provides it's messages exclusively to one consumer at a time.

Notes about synchronization: Much of the work is synchronized on the receivers or messages depending on the work performed. However, anything to do with unacknowledged messages and removed subscriptions must be done synchronized on both (receivers first). This is because there are multiple entry points with the possibility that a message acknowledgement (or NACK) is being processed at the same time as a network failure removes the subscription.

Version:
  $Revision: 1.42.2.1 $
Author:
  Hiram Chirino (Cojonudo14@hotmail.com), Norbert Lataille (Norbert.Lataille@m4x.org), David Maplesden (David.Maplesden@orion.co.nz), Adrian Brock (Adrian@jboss.org)

Constructor Summary
`BasicQueue(JMSDestinationManager server, String description, BasicQueueParameters parameters)` Construct a new basic queue

Method Summary
`void` | `acknowledge(AcknowledgementRequest item, Tx txId)` Acknowledge a message
`void` | `addMessage(MessageReference mes, Tx txId)` Add a message to the queue
`void` | `addReceiver(Subscription sub)` Add a receiver to the queue
`void` | `addSubscriber(Subscription sub)` Add a subscription from the queue
`protected void` | `addToReceivers(Subscription sub)` Add a receiver
`SpyMessage[]` | `browse(String selector)` Browse the queue
`protected void` | `clearEvent(MessageReference message)` Clear the event for a message
`protected void` | `clearEvents()` Clear all the events
`void` | `createMessageCounter(String name, String subscription, boolean topic, boolean durable, int daycountmax)` Create message counter object
`protected void` | `dropMessage(MessageReference message)` Remove a message
`protected void` | `dropMessage(MessageReference message, Tx txid)` Remove a message
`String` | `getDescription()` Retrieve the unique description for this queue
`MessageCounter` | `getMessageCounter()` Get message counter object
`int` | `getQueueDepth()` Retrieve the queue depth
`ArrayList` | `getReceivers()` Retrieve the receivers waiting for a message
`int` | `getReceiversCount()` Retrieve the number of receivers waiting for a message
`int` | `getScheduledMessageCount()` Returns the number of scheduled messages in the queue
`boolean` | `isInUse()` Test whether the queue is in use
`void` | `nackMessages(Subscription sub)` Nack all messages for a subscription
`protected void` | `queueMessageForSending(Subscription sub, MessageReference message)` Queue a message for sending through the client consumer
`SpyMessage` | `receive(Subscription sub, boolean wait)` Receive a message from the queue
`void` | `removeAllMessages()`
`protected void` | `removeReceiver(Subscription sub)` Remove a receiver
`void` | `removeSubscriber(Subscription sub)` Removes a subscription from the queue
`void` | `restoreMessage(MessageReference mes)` Restores a message.
`protected void` | `setupMessageAcknowledgement(Subscription sub, MessageReference messageRef)` Setup a message acknowledgement
`void` | `stop()`
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### BasicQueue

    public BasicQueue(JMSDestinationManager server,
                      String description,
                      BasicQueueParameters parameters)
               throws javax.jms.JMSException

  Construct a new basic queue

Parameters:
  `server` - the destination manager
  `description` - a description to uniquely identify the queue
  `parameters` - the basic queue parameters

Method Detail

### getDescription

    public String getDescription()

  Retrieve the unique description for this queue

  Returns:
    the description

### getReceiversCount

    public int getReceiversCount()

  Retrieve the number of receivers waiting for a message

  Returns:
    the number of receivers

### getReceivers

    public ArrayList getReceivers()

  Retrieve the receivers waiting for a message

  Returns:
    an array of subscriptions

### isInUse

    public boolean isInUse()

  Test whether the queue is in use

  Returns:
    true when there are subscribers

### addReceiver

    public void addReceiver(Subscription sub)
                     throws javax.jms.JMSException

  Add a receiver to the queue

  Parameters:
    `sub` - the subscription to add
  Throws:
    `javax.jms.JMSException`

### addSubscriber

    public void addSubscriber(Subscription sub)
                       throws javax.jms.JMSException

  Add a subscription from the queue

  Parameters:
    `sub` - the subscription to add
  Throws:
    `javax.jms.JMSException`

### removeSubscriber

    public void removeSubscriber(Subscription sub)

  Removes a subscription from the queue

  Parameters:
    `sub` - the subscription to remove

### getQueueDepth

    public int getQueueDepth()

  Retrieve the queue depth

  Returns:
    the number of messages in the queue

### getScheduledMessageCount

    public int getScheduledMessageCount()

  Returns the number of scheduled messages in the queue

### addMessage

    public void addMessage(MessageReference mes,
                           Tx txId)
                    throws javax.jms.JMSException

  Add a message to the queue

  Parameters:
    `mes` - the message reference
    `txId` - the transaction
  Throws:
    `javax.jms.JMSException` - for any error

### restoreMessage

    public void restoreMessage(MessageReference mes)

  Restores a message.

### browse

    public SpyMessage[] browse(String selector)
                        throws javax.jms.JMSException

  Browse the queue

  Parameters:
    `selector` - the selector to apply, pass null for all messages
  Throws:
    `javax.jms.JMSException` - for any error

### receive

    public SpyMessage receive(Subscription sub,
                              boolean wait)
                       throws javax.jms.JMSException

  Receive a message from the queue

  Parameters:
    `wait` - whether to wait for a message
  Throws:
    `javax.jms.JMSException` - for any error

### acknowledge

    public void acknowledge(AcknowledgementRequest item,
                            Tx txId)
                     throws javax.jms.JMSException

  Acknowledge a message

  Parameters:
    `item` - the acknowledgement request
  Throws:
    `javax.jms.JMSException` - for any error

### nackMessages

    public void nackMessages(Subscription sub)

  Nack all messages for a subscription

  Parameters:
    `sub` - the subscription

### removeAllMessages

    public void removeAllMessages()
                           throws javax.jms.JMSException

  Throws:
    `javax.jms.JMSException`

### stop

    public void stop()

### createMessageCounter

    public void createMessageCounter(String name,
                                     String subscription,
                                     boolean topic,
                                     boolean durable,
                                     int daycountmax)

  Create message counter object

  Parameters:
    `name` - topic/queue name
    `subscription` - topic subscription
    `topic` - topic flag
    `durable` - durable subscription flag
    `daycountmax` - message history day count limit 0: disabled, >0: max day count, <0: unlimited

### getMessageCounter

    public MessageCounter getMessageCounter()

  Get message counter object

  Returns:
    MessageCounter message counter object or null

### toString

    public String toString()

### clearEvents

    protected void clearEvents()

  Clear all the events

### clearEvent

    protected void clearEvent(MessageReference message)

  Clear the event for a message

  Parameters:
    `message` - the message reference

### addToReceivers

    protected void addToReceivers(Subscription sub)
                           throws javax.jms.JMSException

  Add a receiver

  Parameters:
    `sub` - the receiver to add
  Throws:
    `javax.jms.JMSException`

### removeReceiver

    protected void removeReceiver(Subscription sub)

  Remove a receiver

  Parameters:
    `sub` - the receiver to remove

### queueMessageForSending

    protected void queueMessageForSending(Subscription sub,
                                          MessageReference message)

  Queue a message for sending through the client consumer

  Parameters:
    `sub` - the subscirption to receive the message
    `message` - the message reference to queue

### setupMessageAcknowledgement

    protected void setupMessageAcknowledgement(Subscription sub,
                                               MessageReference messageRef)
                                        throws javax.jms.JMSException

  Setup a message acknowledgement

  Parameters:
    `sub` - the subscription receiving the message
    `messageRef` - the message to be acknowledged
  Throws:
    `javax.jms.JMSException` - for any error

### dropMessage

    protected void dropMessage(MessageReference message)

  Remove a message

  Parameters:
    `message` - the message to remove

### dropMessage

    protected void dropMessage(MessageReference message,
                               Tx txid)

  Remove a message

  Parameters:
    `message` - the message to remove
    `txid` - the transaction context for the removal

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 JBoss Group, LLC. All Rights Reserved.