org.soyatec.windowsazure.queue
Interface IQueue


public interface IQueue

Objects of this class represent a queue in a user's storage account.


Field Summary
static int DEFAULT_POLL_INTERVAL
          The default time interval between polling the queue for messages.
 
Method Summary
 void addMessageReceivedListener(IMessageReceivedListener listener)
          Adds the listener to the collection of listeners who will be notified when a new message is put into the queue.
 boolean clear()
          Delete all messages in a queue.
 boolean createQueue()
          Creates a queue in the specified storage account.
 boolean deleteMessage(IMessage msg)
          Deletes a message from the queue.
 boolean deleteQueue()
          Deletes the queue.
 StorageAccountInfo getAccount()
          Returns the account info object this queue lives in.
 int getApproximateCount()
          Retrieves the approximate number of messages in a queue.
 java.lang.String getLastStatus()
          Return the last status of the queue.
 IMessage getMessage()
          Retrieves a message from the queue.
 IMessage getMessage(int visibilityTimeoutInSeconds)
          Retrieves a message and sets its visibility timeout to the specified number of seconds.
 java.util.List<org.soyatec.windowsazure.queue.internal.Message> getMessages(int numberOfMessages)
          Tries to retrieve the given number of messages.
 java.util.List<org.soyatec.windowsazure.queue.internal.Message> getMessages(int numberOfMessages, int visibilityTimeoutInSeconds)
          Tries to retrieve the given number of messages.
 java.lang.String getName()
          Returns the name of this queue.
 int getPollInterval()
          Return the poll interval of checking new messages in milliseconds.
 IQueueProperties getProperties()
          Retrieves the queue's properties.
 java.net.URI getQueueUri()
          Return the URI of the queue.
 IRetryPolicy getRetryPolicy()
          Returns the retry policy used for retrying requests.
 org.soyatec.windowsazure.internal.util.TimeSpan getTimeout()
          Returns the timeout of requests.
 boolean isQueueExist()
          Determines whether a queue with the same name already exists in an account.
 boolean isUsePathStyleUris()
          Returns whether to use/generate path-style or host-style URIs.
 IMessage peekMessage()
          Get a message from the queue but do not actually dequeue it.
 java.util.List<org.soyatec.windowsazure.queue.internal.Message> peekMessages(int numberOfMessages)
          Tries to get a copy of messages in the queue without actually dequeuing the messages.
 boolean putMessage(IMessage msg)
          Puts a message in the queue.
 boolean putMessage(IMessage msg, int timeToLiveInSeconds)
          Puts a message in the queue.
 void removeMessageReceivedListener(IMessageReceivedListener listener)
          Removes the listener from the collection of listeners who will when a new message is put into the queue.
 void setPollInterval(int pollInterval)
          Specify the poll interval of checking new messages in milliseconds.
 boolean setProperties(IQueueProperties properties)
          Sets the properties of a queue.
 void setQueueUri(java.net.URI uri)
          Set the URI of the queue
 void setRetryPolicy(IRetryPolicy retryPolicy)
          Specify the retry policy used for retrying requests.
 void setTimeout(org.soyatec.windowsazure.internal.util.TimeSpan timeout)
          Specify the timeout of requests.
 boolean startReceiving()
          Starts the automatic receiving messages.
 void stopReceiving()
          Stop the automatic receiving messages.
 

Field Detail

DEFAULT_POLL_INTERVAL

static final int DEFAULT_POLL_INTERVAL
The default time interval between polling the queue for messages. Polling is only enabled if the user has called startReceiving() .

See Also:
Constant Field Values
Method Detail

createQueue

boolean createQueue()
                    throws StorageException
Creates a queue in the specified storage account.

Returns:
true if the queue was successfully created.
Throws:
StorageException - If queue is exist, a StorageException is throwed.

isQueueExist

boolean isQueueExist()
Determines whether a queue with the same name already exists in an account.

Returns:
true if a queue with the same name already exists.

deleteQueue

boolean deleteQueue()
                    throws StorageException
Deletes the queue. The queue will be deleted regardless of whether there are messages in the queue or not.

Returns:
true if the queue was successfully deleted.
Throws:
StorageException

setProperties

boolean setProperties(IQueueProperties properties)
                      throws StorageException
Sets the properties of a queue.

Parameters:
properties - The queue's properties to set.
Returns:
true if the properties were successfully written to the queue.
Throws:
StorageException

getProperties

IQueueProperties getProperties()
                               throws StorageException
Retrieves the queue's properties.

Returns:
The queue's properties.
Throws:
StorageException

getApproximateCount

int getApproximateCount()
                        throws StorageException
Retrieves the approximate number of messages in a queue.

Returns:
The approximate number of messages in this queue.
Throws:
StorageException

putMessage

boolean putMessage(IMessage msg)
                   throws StorageException
Puts a message in the queue.

Parameters:
msg - The message to store in the queue.
Returns:
true if the message has been successfully enqueued.
Throws:
StorageException

putMessage

boolean putMessage(IMessage msg,
                   int timeToLiveInSeconds)
                   throws StorageException
Puts a message in the queue.

Parameters:
msg - The message to store in the queue.
timeToLiveInSeconds - The time to live for the message in seconds.
Returns:
true if the message has been successfully enqueued.
Throws:
StorageException

getMessage

IMessage getMessage()
                    throws StorageException
Retrieves a message from the queue.

Returns:
The message retrieved or null if the queue is empty.
Throws:
StorageException

getMessage

IMessage getMessage(int visibilityTimeoutInSeconds)
                    throws StorageException
Retrieves a message and sets its visibility timeout to the specified number of seconds.

Parameters:
visibilityTimeoutInSeconds - Visibility timeout of the message retrieved in seconds.
Returns:
Throws:
StorageException

getMessages

java.util.List<org.soyatec.windowsazure.queue.internal.Message> getMessages(int numberOfMessages)
                                                                            throws StorageException
Tries to retrieve the given number of messages.

Parameters:
numberOfMessages - Maximum number of messages to retrieve.
Returns:
The list of messages retrieved.
Throws:
StorageException

getMessages

java.util.List<org.soyatec.windowsazure.queue.internal.Message> getMessages(int numberOfMessages,
                                                                            int visibilityTimeoutInSeconds)
                                                                            throws StorageException
Tries to retrieve the given number of messages.

Parameters:
numberOfMessages - Maximum number of messages to retrieve.
visibilityTimeoutInSeconds - The visibility timeout of the retrieved messages in seconds.
Returns:
The list of messages retrieved.
Throws:
StorageException

peekMessage

IMessage peekMessage()
                     throws StorageException
Get a message from the queue but do not actually dequeue it. The message will remain visible for other parties requesting messages.

Returns:
The message retrieved or null if there are no messages in the queue.
Throws:
StorageException

peekMessages

java.util.List<org.soyatec.windowsazure.queue.internal.Message> peekMessages(int numberOfMessages)
                                                                             throws StorageException
Tries to get a copy of messages in the queue without actually dequeuing the messages. The messages will remain visible in the queue.

Parameters:
numberOfMessages - Maximum number of message to retrieve.
Returns:
The list of messages retrieved.
Throws:
StorageException

deleteMessage

boolean deleteMessage(IMessage msg)
                      throws StorageException
Deletes a message from the queue.

Parameters:
msg - The message to retrieve with a valid popreceipt.
Returns:
true if the operation was successful.
Throws:
StorageException

clear

boolean clear()
              throws StorageException
Delete all messages in a queue.

Returns:
true if all messages were deleted successfully.
Throws:
StorageException

startReceiving

boolean startReceiving()
Starts the automatic receiving messages.

Returns:
true if the operation was successful.

stopReceiving

void stopReceiving()
Stop the automatic receiving messages.


addMessageReceivedListener

void addMessageReceivedListener(IMessageReceivedListener listener)
Adds the listener to the collection of listeners who will be notified when a new message is put into the queue.

Parameters:
listener - the listener which should be notified

removeMessageReceivedListener

void removeMessageReceivedListener(IMessageReceivedListener listener)
Removes the listener from the collection of listeners who will when a new message is put into the queue.

Parameters:
listener - the listener which should no longer be notified

getName

java.lang.String getName()
Returns the name of this queue.

Returns:
The name of this queue.

getAccount

StorageAccountInfo getAccount()
Returns the account info object this queue lives in.

Returns:
The account info object this queue lives in

isUsePathStyleUris

boolean isUsePathStyleUris()
Returns whether to use/generate path-style or host-style URIs.

Returns:
whether to use/generate path-style or host-style URIs.

getQueueUri

java.net.URI getQueueUri()
Return the URI of the queue.

Returns:
The URI of the queue

setQueueUri

void setQueueUri(java.net.URI uri)
Set the URI of the queue

Parameters:
uri -

getRetryPolicy

IRetryPolicy getRetryPolicy()
Returns the retry policy used for retrying requests.

Returns:
The retry policy used for retrying requests.

setRetryPolicy

void setRetryPolicy(IRetryPolicy retryPolicy)
Specify the retry policy used for retrying requests.

Parameters:
retryPolicy - The retry policy used for retrying requests.

getTimeout

org.soyatec.windowsazure.internal.util.TimeSpan getTimeout()
Returns the timeout of requests.

Returns:
The timeout of requests.

setTimeout

void setTimeout(org.soyatec.windowsazure.internal.util.TimeSpan timeout)
Specify the timeout of requests.

Parameters:
timeout - The timeout of requests.

getPollInterval

int getPollInterval()
Return the poll interval of checking new messages in milliseconds.

Returns:
The poll interval in milliseconds.

setPollInterval

void setPollInterval(int pollInterval)
Specify the poll interval of checking new messages in milliseconds.

Parameters:
pollInterval - The poll interval in milliseconds.

getLastStatus

java.lang.String getLastStatus()
Return the last status of the queue.

Returns:
the last status of the queue.