public class

SQSConnector

extends Object
java.lang.Object
   ↳ org.mule.modules.amazon.SQSConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Amazon Simple Queue Service (Amazon SQS) is a distributed queue messaging service introduced by Amazon.com in April of 2006. It supports programmatic sending of messages via web service applications as a way to communicate over the internet. The intent of SQS is to provide a highly scalable hosted message queue that resolves issues arising from the common producer-consumer problem or connectivity between producer and consumer.

This connector does not provide a method for creating a queue. The reason being that it will automatically create it when its needed instead of having to manually specify so.

Summary

Fields
private String accessKey AWS access id
private static Logger logger
private MessageQueue msgQueue Message Queue
private String secretAccessKey AWS secret access id
Public Constructors
SQSConnector()
Public Methods
void addPermission(String label, String accountId, String action)
Adds a permission to this message queue.
void connect(String queueName)
Map<String, Object> createProperties(Message msg)
void deleteMessage(String receiptHandle)
Deletes the message identified by message object on the queue this object represents.
void deleteQueue()
Deletes the message queue represented by this object.
void disconnect()
String getAccessKey()
int getApproximateNumberOfMessages()
Gets the visibility timeout for the queue.
String getMessageQueueUrl()
Map<String, String> getQueueAttributes(QueueAttribute attribute)
Gets queue attributes.
String getSecretAccessKey()
URL getUrl()
This method provides the URL for the message queue represented by this object.
boolean isConnected()
void receiveMessages(SourceCallback callback, Integer visibilityTimeout, Boolean preserveMessages, Long pollPeriod, Integer numberOfMessages)
Attempts to receive a message from the queue.
void removePermission(String label)
Removes a permission from this message queue.
void sendMessage(String message)
Sends a message to a specified queue.
void setAccessKey(String accessKey)
void setQueueAttribute(QueueAttribute attribute, String value)
Sets a queue attribute.
void setSecretAccessKey(String secretAccessKey)
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private String accessKey

AWS access id

private static Logger logger

private MessageQueue msgQueue

Message Queue

private String secretAccessKey

AWS secret access id

Public Constructors

public SQSConnector ()

Public Methods

public void addPermission (String label, String accountId, String action)

Adds a permission to this message queue.

Parameters
label A name for this permission
accountId The AWS account ID for the account to share this queue with
action A value to indicate how much to share (SendMessage, ReceiveMessage, ChangeMessageVisibility, DeleteMessage, GetQueueAttributes)
Throws
SQSException wraps checked exceptions

public void connect (String queueName)

Parameters
queueName The name of the queue to connect to
Throws
ConnectionException If a connection cannot be made

public Map<String, Object> createProperties (Message msg)

Parameters
msg

public void deleteMessage (String receiptHandle)

Deletes the message identified by message object on the queue this object represents.

Parameters
receiptHandle Receipt handle of the message to be deleted
Throws
SQSException wraps checked exceptions

public void deleteQueue ()

Deletes the message queue represented by this object. Will delete non-empty queue.

Throws
SQSException wraps checked exceptions

public void disconnect ()

public String getAccessKey ()

public int getApproximateNumberOfMessages ()

Gets the visibility timeout for the queue.

Returns
  • the approximate number of messages in the queue
Throws
SQSException wraps checked exceptions

public String getMessageQueueUrl ()

public Map<String, String> getQueueAttributes (QueueAttribute attribute)

Gets queue attributes. This is provided to expose the underlying functionality. Currently supported attributes are; ApproximateNumberOfMessages CreatedTimestamp LastModifiedTimestamp VisibilityTimeout RequestPayer Policy

Parameters
attribute Attribute to get
Returns
  • a map of attributes and their values
Throws
SQSException wraps checked exceptions

public String getSecretAccessKey ()

public URL getUrl ()

This method provides the URL for the message queue represented by this object.

Returns
  • generated queue service url

public boolean isConnected ()

public void receiveMessages (SourceCallback callback, Integer visibilityTimeout, Boolean preserveMessages, Long pollPeriod, Integer numberOfMessages)

Attempts to receive a message from the queue. Every attribute of the incoming message will be added as an inbound property. Also the following properties will also be added:

sqs.message.id = containing the message identification sqs.message.receipt.handle = containing the message identification

Parameters
callback Callback to call when a new message is available.
visibilityTimeout The duration (in seconds) the retrieved message is hidden from subsequent calls to retrieve.
preserveMessages Flag that indicates if you want to preserve the messages in the queue. False by default, so the messages are going to be deleted.
pollPeriod Time in milliseconds to wait between polls (when no messages were retrieved). Default period is 1000 ms.
numberOfMessages The number of messages to be retrieved on each call (10 messages max). By default, 1 message will be retrieved.
Throws
SQSException wraps checked exceptions

public void removePermission (String label)

Removes a permission from this message queue.

Parameters
label A name for the permission to be removed
Throws
SQSException wraps checked exceptions

public void sendMessage (String message)

Sends a message to a specified queue. The message must be between 1 and 256K bytes long.

Parameters
message The message to send. Defaults to the payload of the Mule message.
Throws
SQSException if something goes wrong

public void setAccessKey (String accessKey)

Parameters
accessKey

public void setQueueAttribute (QueueAttribute attribute, String value)

Sets a queue attribute. This is provided to expose the underlying functionality, although the only attribute at this time is visibility timeout.

Parameters
attribute Name of the attribute being set
value The value being set for this attribute
Throws
SQSException wraps checked exceptions

public void setSecretAccessKey (String secretAccessKey)

Parameters
secretAccessKey