Queue
The Queue interface is another simple API for pushing and pulling messages to and from a queue.
public interface Queue { String pull(); void push(String task); String getName(); void setName(String name); void startPolling(); void stopPolling();}Currently this interface is implemented by the AWSQueue class which relies on the AWS Simple Queue Service, and by
LocalQueue which is based on a ConcurrentLinkedQueue. The implementation to load is configurable through:
para.q = "sqs"# orpara.q = "local"AWSQueue
Section titled “AWSQueue”The AWS SQS plugin uses Amazon’s SQS as a river by long polling for messages from a given queue.
The code continuously pulls messages from an SQS queue. After a message is processed, it gets deleted from the queue.
To enable this functionality, set para.queue_link_enabled = true in the Para configuration file.
Sample code:
AWSQueue q = new AWSQueue("myQueue");AWSQueueUtils.pushMessages(q.getUrl(), listOfMessages);List<String> result = AWSQueueUtils.pullMessages(q.getUrl(), 10);To configure, put this in your para-application.conf:
para.queue.polling_sleep_seconds: 60para.queue.polling_interval_seconds: 20Messages are in the same format as all other Para objects (see Sysprop):
{ "id": "id_OR_null", "appid": "para_app_id", "type": "para_data_type", "properties": { "key1": "value1" ...}}When the queue is empty the river will sleep for sleep seconds before sending a new request for messages to the queue.
Long polling is done by the Amazon SQS client using the waitTimeSeconds attribute which is set to longpolling_interval (must be between 0 and 20).
LocalQueue
Section titled “LocalQueue”This queue implementation is good for local development, testing and single-machine Para servers. It uses an in-memory queue which is not persisted in any way.