Amazon Queuing Service

Section 1 - Basic Operations

Introduction

The purpose of this example is to implement a user-friendly Queue Service with all possible operations such as Creating Queue, Reading etc, via Axis2-M2 SOAP engine. The Amazon Simple Queue Service (Beta 2) from amazon.com has been chosen for this example as the Web Service Provider.

Using the Amazon Simple Queue Service, developers can decouple components of their application so that they run independently. The Simple Queue Service provides the message management between the independent components. Any component of a distributed application can store any type of data in a reliable queue at Amazon.com. Another component or application can retrieve the data using queue semantics. More information on this service visit here

In this example String objects are used to store in the Amazon queue.

Description of the operations is available at http://webservices.amazon.com/AWSSimpleQueueService/AWSSimpleQueueService.wsdl

Getting Started

The users who need to get the Web services out of this queue need to be registered with the amazon.com, as a developer. (For this particular example a key has been obtained from Amazon and via property file it has called to OMElement). Once being registered, a subscription Id will be given. This key has to be used with your code to get the required Web services. The key that is being obtained, should be incorporated to the key.properties file, which is located at ${user.dir}\modules\samples\properties

Registration can be done at http://www.amazon.com/gp/aws/registration/registration-form.html

There are seven services available for this queue from Amazon. Create Queue, Configure Queue, List My Queues, En-queue, Read and De-queue. For this example Create Queue, En-queue, Read and List My Queues have been implemented.

En-queue operation has not been implemented. This operation has left out for users to implement. It is expected that once the user has implemented this operation, the fundamental perspective of the Axis2-M2 over Web Services is dealt with perfectly.

The code is based on invokeNonBlocking(String, OMElement, Callback) operation to understand the maximum flexibility of the Axis2-M2.

Operations

The manipulation of the queue is divided in to two categories,

IN operations

In these operations user will be given the autonomy to create a new queue or use an existing queue to enqueue the selected queue. Only one queue is subjected to manipulate at a given instance.

OUT operations

In these operations user will be given the autonomy to list the queues that once possess for a given subscription Id and read the entries of a particular queue or if the queue is empty the queue can deliberately be deleted. If the queue is not empty, the delete operation will not work. The queue must empty before it has to be deleted. It is expected that the user to implement the de-queue operation in order to get the full understanding of the code. Necessary steps will be provided at the end of this documentation.

On the perimeters of this example, I have generated a key (0HPJJ4GJDSG2TZ2C8X02) which is the subscription Id and hard coded to the key.properties file and OMElement objects obtained the value through Properties API, for each operation invocation. The service end point also hard coded, (http://webservices.amazon.com/onca/soap?Service=AWSSimpleQueueService ). Thus, when a user reads the queues available, queues pertaining to this key will be displayed.

Section 2 - Architecture and Advanced Operations

Architecture of the Code

The structure of the code has been divided in to three sections for the simplicity of understanding.

OMElement for relevant operations are carried out by CreateQueue, DeleteQueue, Enqueue and Read classes. Event Listener for IN operations is carried by ListenersIn and OUT operations ListenersOut classes. Separate threads are created by RunnableXXX classes. Extended classes from Callback handled by SimpleQueueXXXCallbackHandler classes.

Once a event is generated by AmazonSimpleQueueServiceXX class, the event is handled by ListnersXX class. The listener classs has references to RunnableXXX class, which is carried out the Axis2-M2 execution code.

Once an event is generated by AmazonSimpleQueueServiceXX class, the event is handled by ListnersXX class. The listener class has a reference to RunnableXXX class, which contains the Axis2-M2 execution code. RunnableXXX class has references to classes that support OMElement, which is needed as references to invokeNonBlocking(String, OMElement,Callback) method and SimpleQueueXXXCallbackHandler classes. Once the onComplete() method executes, the response is send back to GUI's response handling components. Figure below shows the schematic architecture of the sample.


All the Web services are available as rpc-literal encoded style. Thus, OMElemnts adheres to this requirement.

Running the Samples

  1. IN operations – Go to ${user.dir}/modules/samples and type “ant amazonIn”
  2. OUT operations – Go to ${user.dir}/modules/samples and type “ant amazonOut”

GUI for IN operations is popped by Running RunGUICQ class and OUT operations is popped by running RunGUIRQ class.

Handling the GUI Components

Guide to Create the Dequeue Operation

  1. It is recommended that the user go through with the Dequeue operation description from WSDL.
  2. Write your custom Callback class to handle the onComplete() method.
  3. Write the OMElement which corresponds Dequeue opreation.
  4. Write the class which implements the Runnable interface to handle the invokeNonBlocking() method.
  5. Write the event handler to execute the above mentioned class.
  6. Add a Component to the AmazonSimpleQueueServieOut GUI class and add the above class as an action listener.