예제 #1
0
        static void SendMessage(AmazonSQSClient client)
        {
            string      id = Guid.NewGuid().ToString();
            DOEvent     ev = new DOEvent();
            DOParameter pa = new DOParameter();

            ev.event_id   = id;
            ev.event_name = "purchase";
            ev.user_id    = id;
            pa.order_id   = id;
            pa.currency   = "krw";
            pa.price      = 300;
            ev.parameters = pa;

            var req = new SendMessageRequest();

            req.QueueUrl    = QUEUE_URL;
            req.MessageBody = JsonConvert.SerializeObject(ev);
            var response = client.SendMessageAsync(req).Result;

            Console.WriteLine("status code: " + response.HttpStatusCode);
            Console.WriteLine("md5 body: " + response.MD5OfMessageBody);
            Console.WriteLine("msg id: " + response.MessageId);
            Console.WriteLine("msg length: " + response.ContentLength);
        }
예제 #2
0
        public IActionResult PostEvent(DOEvent e)
        {
            AmazonSQSClient SQS_Client = new AmazonSQSClient(awsCredential, RegionEndpoint.APNortheast2);
            var             request    = new SendMessageRequest();

            request.QueueUrl    = SQS_QUEUE_URL;
            request.MessageBody = JsonConvert.SerializeObject(e);
            var response = SQS_Client.SendMessageAsync(request).Result;

            if ((int)response.HttpStatusCode >= 200 && (int)response.HttpStatusCode <= 299)
            {
                return(Ok(new { is_success = true }));
            }
            else
            {
                return(StatusCode(500));
            }
        }