This article contains an example that shows how to send and consume messages from a Message queue with the Queue API, using AWS SQS.
The code consists of the following:
1. Connect to the AWS SQS using the AWSQueue.MessageQueueProvider external object.
2. It returns a MessageQueue EO which should be used to send the message to the Queue.
3. The result is returned in a variable of type MessageResult SDT.
Next, create a GeneXus object and define the following:
&queueURL = !"https://sqs.us-east-1.amazonaws.com/xxxxx/gxfullgx-test-queueapi"
&accessKey = !"xxxxxxxxxxxxxxxx"
&secretKey = !"xxxxxxxxxxxxxxxxxxxxxxxx"
®ion = !"us-east-1"
&AWSBasicCredentials.AccessKey = &accessKey //AWSBasicCredentials SDT is under AWSCore module
&AWSBasicCredentials.SecretKey = &secretKey
&AWSBasicCredentials.Region = ®ion
&MessageQueue = AWSQueue.MessageQueueProvider.Connect(&AWSBasicCredentials,&queueURL,&errorMessages,&isOK) //GeneXusMessagingQueue.SimpleQueue.MessageQueue
&Message = new()
&Message.MessageId = GUID.NewGuid().ToString().Trim()
&Message.MessageBody = !"test1 send one message"
&MessageProperty = new() //GeneXusMessagingQueue.SimpleQueue.MessageProperty
&MessageProperty.PropertyKey = !"key1"
&MessageProperty.PropertyValue = !"Value1"
&Message.MessageAttributes.Add(&MessageProperty)
&MessageProperty = new()
&MessageProperty.PropertyKey = !"key2"
&MessageProperty.PropertyValue = !"Value2"
&Message.MessageAttributes.Add(&MessageProperty)
&Messages.Add(&Message)
&MessageOptions.MaxNumberOfMessages = 10 //GeneXusMessagingQueue.SimpleQueue.MessageOptions
&MessageResultCollection = &MessageQueue.SendMessages(&Messages,&MessageOptions,&errorMessages,&success) //GeneXusMessagingQueue.SimpleQueue.MessageResult Collection
&MessageCollection = &MessageQueue.ReceiveMessages(&errorMessages,&success) //GeneXusMessagingQueue.SimpleQueue.Message Collection
//Process &MessageCollection