Search by Tags

Cloud Sqs Lib API

 

Article updated at 28 Oct 2017
Compare with Revision

Subscribe for this article updates

Attention: this is a legacy library and thus not supported by Toradex anymore. We recommend that you use the new libraries for all Toradex modules. Please see the Toradex CE Libraries and Code Samples for up-to-date information.

Contains function declarations to be used to access AWS Cloud SQS Services Colibri Modules [PXAxxx, Tegra T20], WinCE 6.0 / 7.0 . More...

Macros

#define  AWS_SQS_ACCESS_ID_MAX_LENGTH  20
AWS Account ID string Length.
#define  AWS_SQS_SECRET_KEY_MAX_LENGTH  40
AWS Account Secret Kay String Length.
#define  AWS_SQS_OWNER_ID_MAX_LENGTH  12
AWS Account Owner ID String Length.
#define  AWS_SQS_SIGNATURE_HASH_LENGTH  32
#define  AWS_SQS_SIGNATURE_STRING_LENGTH  44
#define  SQS_QUEUE_NAME_MAX_LENGTH  80
#define  SQS_MAX_TIME_STRING_LENGTH  24
#define  SQS_MESSAGE_ID_LENGTH  100
#define  SQS_MESSAGE_DELAY_SECONDS_MAX  900
#define  SQS_MESSAGE_BODY_MAX_LENGTH  (64 * 1024)
#define  SQS_RECIEPT_HANDLE_MAX_LENGTH  1024
#define  SQS_ATTRIBUTE_NAME_BUFFER_SIZE  24
#define  SQS_HTTP_RESPONSE_DATA_BUFFER_SMALL  (2 * 1024)
#define  SQS_HTTP_RESPONSE_DATA_BUFFER_LARGE  (4 * 1024)
#define  SQS_HTTP_ARGUMENT_BUFFER_SMALL  (2 * 1024)
#define  SQS_HTTP_ARGUMENT_BUFFER_LARGE  (4 * 1024)
#define  SQS_STRING_TO_SIGN_BUFFER_SMALL  (2 * 1024)
#define  SQS_STRING_TO_SIGN_BUFFER_LARGE  (4 * 1024)
#define  URL_ENCODED_RECEIPT_HANDLE_BUFFER  (4 * 1024)
#define  SQS_HANDLE_MEMORY_ALLOCATION  (4 * 5)
#define  QUEUE_ATTRIBUTE_VISIBILITY_TIMEOUT  1
#define  QUEUE_ATTRIBUTE_MAXIMUM_MESSAGE_SIZE  2
#define  QUEUE_ATTRIBUTE_MESSAGE_RETENTION_PERIOD  3
#define  QUEUE_ATTRIBUTE_DELAY_SECONDS  4

Functions

BOOL  SqsOpenQueue (char *accessID, char *secretKey, char *path, char *accountOwnerID, char *queueName, HSQS *sqsQueue)
BOOL  SqsCloseQueue (HSQS *sqsQueue)
BOOL  SqsSendMessage (HSQS sqsQueue, char *message, DWORD delaySeconds, char *messageID, DWORD messageIDSize)
BOOL  SqsReceiveMessage (HSQS sqsQueue, char *attributeName, BYTE maxNumberOfMessages, DWORD visibilityTimeout, char *message, char *messageID, char *recieptHandle)
BOOL  SqsDeleteQueue (HSQS sqsQueue)
BOOL  SqsCreateQueue (HSQS sqsQueue)
BOOL  SqsGetQueueUrl (HSQS sqsQueue, char *dataOut, DWORD dataOutSize)
BOOL  SqsListQueues (HSQS sqsQueue, char *queueNamePrefix, char *filePath)
BOOL  SqsFindQueue (const char *filePath, char *dataOut, DWORD dataOutSize, DWORD *pointerToNextTopic, DWORD fileSize)
BOOL  SqsGetQueueAttributes (HSQS sqsQueue, char *dataOut, DWORD dataOutSize)
BOOL  SqsSetQueueAttributes (HSQS sqsQueue, DWORD attributeName, int attributeValue)
BOOL  SqsDeleteMessage (HSQS sqsQueue, char *receiptHandle)
BOOL  SqsChangeMessageVisibility (HSQS sqsQueue, char *receiptHandle, DWORD visibilityTimeoutValue)

Detailed Description

Contains function declarations to be used to access AWS Cloud SQS Services Colibri Modules [PXAxxx, Tegra T20], WinCE 6.0 / 7.0 .

Author
Author:
agp
Version
Rev:
1154
Date
Date:
2012-11-08 19:56:19 +0530 (Thu, 08 Nov 2012)

Function Documentation

BOOL SqsChangeMessageVisibility ( HSQS  sqsQueue,
char *  receiptHandle,
DWORD  visibilityTimeoutValue
)

Changes Message's Visibility Timeout attribute

Parameters
[in] sqsQueue Handle returned by call to SqsOpenQueue()
[in] receiptHandle Pointer to the string returned by call to SqsReceiveMessage()
[in] visibilityTimeoutValue New value for timeout, Range [0 - 900] Seconds
Return values
TRUE Success
FALSE See GetLastError()
BOOL SqsCloseQueue ( HSQS *  sqsQueue )

Deletes already opened SQS Queue Handle

Parameters
[in] sqsQueue Handle returned by call to SqsOpenQueue()
Return values
TRUE Success
FALSE See GetLastError()
BOOL SqsCreateQueue ( HSQS  sqsQueue )

Creates a Queue

Parameters
[in] sqsQueue Handle returned by call to SqsOpenQueue()
Return values
TRUE Success
FALSE See GetLastError()
BOOL SqsDeleteMessage ( HSQS  sqsQueue,
char *  receiptHandle
)

Deletes a Message from a Queue

Parameters
[in] sqsQueue Handle returned by call to SqsOpenQueue()
[in] receiptHandle Pointer to the string returned by call to SqsReceiveMessage()
Return values
TRUE Success
FALSE See GetLastError()
BOOL SqsDeleteQueue ( HSQS  sqsQueue )

Deletes the Queue

Parameters
[in] sqsQueue Handle returned by call to SqsOpenQueue()
Return values
TRUE Success
FALSE See GetLastError()
BOOL SqsFindQueue ( const char *  filePath,
char *  dataOut,
DWORD  dataOutSize,
DWORD *  pointerToNextTopic,
DWORD  fileSize
)

Finds one by one Queue details stored in a local file as a result of function call to SnsListQueues()
File must be initialized by calling SqsListQueues()

Parameters
[in] filePath Local file path in which queue list data is saved
[out] dataOut Pointer to the allocated memory to store returned queue detail, user need to allocate memory
[in] dataOutSize Size of the allocated memory pointed by dataOut
[in,out] pointerToNextTopic Points to next location of detail, to find 1st in the list put NULL
[in] fileSize Size of the file in bytes, pointed by filePath
Return values
TRUE Success
FALSE See GetLastError()
BOOL SqsGetQueueAttributes ( HSQS  sqsQueue,
char *  dataOut,
DWORD  dataOutSize
)

Gets Queue Attributes

Parameters
[in] sqsQueue Handle returned by call to SqsOpenQueue()
[out] dataOut Pointer to the allocated memory to hold Queue attributes data returned by function, user need to allocate memory
[in] dataOutSize Size of the allocated memory
Return values
TRUE Success
FALSE See GetLastError()
BOOL SqsGetQueueUrl ( HSQS  sqsQueue,
char *  dataOut,
DWORD  dataOutSize
)

Gets Queue Url

Parameters
[in] sqsQueue Handle returned by call to SqsOpenQueue()
[out] dataOut Pointer to the allocated memory to hold Queue string returned by the function, user need to allocate memory
[in] dataOutSize Size of the allocated memory for dataOut
Return values
TRUE Success
FALSE See GetLastError()
BOOL SqsListQueues ( HSQS  sqsQueue,
char *  queueNamePrefix,
char *  filePath
)

Lists all Queues in a local file starting with prefix mentioned
Queues are stores in a local file

Parameters
[in] sqsQueue Handle returned by call to SqsOpenQueue()
[in] queueNamePrefix Prefix example "test" to get a list of all queues starting with test or
"t" to get list of all queue starting with letter t
[in] filePath Local file path in which queue list data will be saved
Return values
TRUE Success
FALSE See GetLastError()
BOOL SqsOpenQueue ( char *  accessID,
char *  secretKey,
char *  path,
char *  accountOwnerID,
char *  queueName,
HSQS *  sqsQueue
)

Opens Handle for SQS Queue, the returned sqsQueue Handle is required as an input parameter to every Sqs function call

Parameters
[in] accessID AWS Access ID [20 Characters]
[in] secretKey AWS Secret Key [40 Characters]
[in] path AWS SQS path
[in] accountOwnerID 12 digit unique ID number like, AWS Access ID
[in] queueName Queue names must be constructed using only uppercase/lowercase ASCII letters,
numbers, underscore, hyphen, and must be between 1 and 80 characters long.
[out] sqsQueue Handle to hold various sqs related parameters.
Return values
TRUE Success
FALSE See GetLastError()
BOOL SqsReceiveMessage ( HSQS  sqsQueue,
char *  attributeName,
BYTE  maxNumberOfMessages,
DWORD  visibilityTimeout,
char *  message,
char *  messageID,
char *  recieptHandle
)

Receives message from an existing Queue

Parameters
[in] sqsQueue Handle returned by call to SqsOpenQueue()
[in] attributeName Valid String values: All | SenderId | SentTimestamp | ApproximateReceiveCount | ApproximateFirstReceiveTimestamp
[in] maxNumberOfMessages Maximum number of messages to return, 1 to 10(maximum)
[in] visibilityTimeout The duration (in seconds) that the received messages are hidden
from subsequent retrieve requests after being retrieved by a SqsReceiveMessage() request.
[out] message Pointer to the received Message as string (64KB maximum)
[out] messageID Pointer to the received Message's ID as string, maximum length = 100
[out] recieptHandle Pointer to the recieptHandle as string, it is required by SnsDeleteMessage() call. Maximum length = 1024
Return values
TRUE Success
FALSE See GetLastError() AttributeName, visibilityTimeout, maxNumberOfMessages - working in default mode only for now (kept it for future use)
Put NULL for these input parameters
BOOL SqsSendMessage ( HSQS  sqsQueue,
char *  message,
DWORD  delaySeconds,
char *  messageID,
DWORD  messageIDSize
)

Sends a message to the Queue

Parameters
[in] sqsQueue Handle returned by call to SqsOpenQueue()
[in] message The message you want to send to the queue. Maximum length is 64KB
[in] delaySeconds Number of seconds to delay the message
Messages with a positive delay seconds becomes available for processing after the delay time has elapsed
[out] messageID Successful call to this function will put message ID string on the memory pointed by this pointer, user need to allocate memory
[in] messageIDSize Size of the memory allocated for messageID
Return values
TRUE Success
FALSE See GetLastError()
BOOL SqsSetQueueAttributes ( HSQS  sqsQueue,
DWORD  attributeName,
int  attributeValue
)

Sets Queue Attribute

Parameters
[in] sqsQueue Handle returned by call to SqsOpenQueue()
[in] attributeName Valid values can be from 1 to 4, user should use macros QUEUE_ATTRIBUTE_XXXXXXXXX
[in] attributeValue Value associated with attributeName
Return values
TRUE Success
FALSE See GetLastError()