com.xerox.amazonws.sqs2
Class SQSUtils

java.lang.Object
  extended by com.xerox.amazonws.sqs2.SQSUtils

public class SQSUtils
extends Object

This class provides helper methods to interact with the Amazon Simple Queue Service.

Author:
D. Kavanagh, developer@dotech.com

Constructor Summary
SQSUtils()
           
 
Method Summary
static MessageQueue connectToQueue(String queueName, String accessKey, String secretKey)
          Returns a message queue for a given name, credentials.
static MessageQueue connectToQueue(String serverName, String queueName, String accessKey, String secretKey)
          Returns a message queue for a given name, credentials.
static MessageQueue getMessageQueue(QueueService service, String msgQueueName)
          Deprecated. This method was for compatibility with the old AWS SQS client (@see getQueueOrElse)
static MessageQueue getQueueOrElse(QueueService qs, String queueName)
          This method will block until the requested message queue is fetched or created.
static QueueService getQueueService(String accessKey, String secretKey, String serverName)
          Create a QueueService object for a given URL.
static void sendMessageForSure(MessageQueue queue, String message)
          This method will block until the message has been sent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQSUtils

public SQSUtils()
Method Detail

connectToQueue

public static MessageQueue connectToQueue(String queueName,
                                          String accessKey,
                                          String secretKey)
                                   throws SQSException
Returns a message queue for a given name, credentials. Uses the default SQS host.

Parameters:
queueName - name of the queue to connect to
accessKey - AWS access id
secretKey - AWS secret key
Returns:
object representing the message queue
Throws:
SQSException

connectToQueue

public static MessageQueue connectToQueue(String serverName,
                                          String queueName,
                                          String accessKey,
                                          String secretKey)
                                   throws SQSException
Returns a message queue for a given name, credentials.

Parameters:
serverName - name of the host to use
queueName - name of the queue to connect to
accessKey - AWS access id
secretKey - AWS secret key
Returns:
object representing the message queue
Throws:
SQSException

getQueueService

public static QueueService getQueueService(String accessKey,
                                           String secretKey,
                                           String serverName)
                                    throws SQSException
Create a QueueService object for a given URL.

Parameters:
accessKey - AWS access id
secretKey - AWS secret key
serverName - name of the host to use
Returns:
object representing the queue service
Throws:
SQSException

getMessageQueue

public static MessageQueue getMessageQueue(QueueService service,
                                           String msgQueueName)
                                    throws SQSException
Deprecated. This method was for compatibility with the old AWS SQS client (@see getQueueOrElse)

Looks for a queue by name: if found, return a MessageQuueue object for it. Else, return null.

Parameters:
service - the queue service we're using
msgQueueName - the name of the message queue to find, or create
Returns:
object representing the message queue
Throws:
SQSException

getQueueOrElse

public static MessageQueue getQueueOrElse(QueueService qs,
                                          String queueName)
This method will block until the requested message queue is fetched or created. Good for those times when the app simply must have a message queue to run.

Parameters:
qs - the queue service we're using
queueName - the name of the queue to find or create
Returns:
object representing the message queue

sendMessageForSure

public static void sendMessageForSure(MessageQueue queue,
                                      String message)
This method will block until the message has been sent. Good for those times when the app simply must send the message to proceed.

Parameters:
queue - the queue the message is sent to
message - the message to send