/// <summary> /// Sends a new message to Amazon SQS using /// the specified queue URL. The message size /// limit is 256kb. /// </summary> /// <param name="queueUrl">The sqs queue endpoint to send the message to.</param> /// <param name="message">The message to send via SQS.</param> public static Amazon.SQS.Model.SendMessageResponse Send(string queueUrl, string message) { // Check that there is content for the message. if (string.IsNullOrEmpty(message)) throw new ArgumentException("The message cannot be nothing!"); // Check that the size of the message is okay. int messageSize = System.Text.ASCIIEncoding.Unicode.GetByteCount(message); if ((messageSize / 1000) >= 256) throw new ArgumentException("The message size cannot be larger than 256kb!"); // Send the message to Amazon. Amazon.SQS.Model.SendMessageResponse response = new Amazon.SQS.Model.SendMessageResponse(); using (Amazon.SQS.IAmazonSQS client = new Factory().SQSClient()) { Amazon.SQS.Model.SendMessageRequest request = new Amazon.SQS.Model.SendMessageRequest() { MessageBody = message, QueueUrl = queueUrl }; response = client.SendMessage(request); } return response; }