Add an Amazon SQS Web Reference
Add a Web reference to Amazon SQS WSDL by pointing to http://queue.amazonaws.com/doc/2006-04-01/QueueService.wsdl
as shown in Figure 9
. This will create com.amazonws.queue.*
proxies to access the Amazon SQS service.
The Amazon SQS Dashboard:
|Figure 9. Web Reference to Amazon SQS WSDL: The figure shows how to find the Amazon SQS WSDL file to add the Web reference to your project.|
|Figure 10. The Completed Dashboard: The figure shows the completed Amazon SQS dashboard form, which lets you perform common queue and message operations.||
You are now ready to start using Amazon SQS. Among other files the downloadable code
contains the Windows Form frmHyper
(the file Hyper.cs
see Figure 10
) and a wrapper class for Amazon SQS specific calls named AmazonSQS.cs.
The dashboard lets you list, create, and delete queues (delete is available only when a Queue is empty), and create and delete messages.
Most of the code is self-explanatory, but I'll go over couple of functions in the AmazonSQS.cs
file. The getQueueNames()
method shown below retrieves a list of queues. As shown, you first create an instance of QueueServiceWse (note the "Wse" suffix). All calls require you to construct parameters, which is this case is ListQueue. You pass this parameter to the ListQueues()
function which returns the response, packaged as a ListQueueResponse instance. You then check for success and return the Queue list to the caller.
You will be prompted for a certificate password. This is the same password you supplied when you installed the certificate on Windows.
method is a convenience function that creates an instance of QueueServiceWse and sets the AmazonSQS URL and the name of the WSE application policy you want to use.
public static string getQueueNames()
com.amazonaws.queue.QueueServiceWse queueService =
com.amazonaws.queue.ListQueues listQueues = new
com.amazonaws.queue.ListQueuesResponse listQueueResponse =
if (listQueueResponse == null ||
listQueueResponse.ResponseStatus.StatusCode != SUCCESS)
string queueNames = listQueueResponse.QueueUrl;
private static com.amazonaws.queue.QueueServiceWse
com.amazonaws.queue.QueueServiceWse queueService = new
queueService.Url = "http://queue.amazonaws.com/";
To use the sendMessage()
function, you first create an instance of MessageQueueWse (note the Wse suffix again) that points to a specific queue. Then you create an instance of Message, load the message with string content, and send it using the MessageQueueWse.sendMessage()
method is another convenience function that sets the WSE policy and Queue name. Here's the code for both methods:
public static string sendMessage(string queueURL, string message)
com.amazonaws.queue.MessageQueueWse messageQueue =
com.amazonaws.queue.SendMessage sendMessage = new
sendMessage.MessageBody = message;
com.amazonaws.queue.SendMessageResponse response =
if (response == null || response.ResponseStatus.StatusCode !=
private static com.amazonaws.queue.MessageQueueWse
com.amazonaws.queue.MessageQueueWse messageQueue = new
messageQueue.Url = queueURL;
The attached code contains a number of other useful functions that you can experiment with.
While Amazon SQS provides good basic queuing capabilities, it still does not provide capabilities such as such as journaling, acknowledgements, publish-subscribe, routing, etc that organizations have come to expect from messaging infrastructure. However, given the clout and weight Amazon carries, don't be surprised if such features begin showing up in the future as part of Amazon SQS.