public void ToBody_Flush()
 {
     var entity = new FlushDataStoreRequest() { StoreIdentifier="Sixeyed-CloudServiceBus-ResponseData", ResponseQueueUrl = fixedQueueName };
     var message = new SendMessageRequest();
     message.RequestToBody(entity);
     var expected = @"{""ResponseQueueName"":""b1a84e89-e5b9-4720-9235-dcf9605a59c3"",""ServiceRequestName"":""FlushDataStoreRequest"",""StoreIdentifier"":""Sixeyed-CloudServiceBus-ResponseData""}";
     Assert.AreEqual(expected, message.MessageBody);
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.Title = "CloudServiceBus: Client";

            AmazonSQS sqs = AwsFacade.GetSqsClient();
            var requestQueueUrl = ConfigurationManager.AppSettings["QueueUrl"];

            //create a queue for responses:
            var queueName = Guid.NewGuid().ToString();
            var createQueueRequest = new CreateQueueRequest();
            createQueueRequest.QueueName = queueName;
            var createQueueResponse = sqs.CreateQueue(createQueueRequest);
            var responseQueueUrl = createQueueResponse.CreateQueueResult.QueueUrl;

            var listener = new MessageListener();
            ThreadPool.QueueUserWorkItem(new WaitCallback(listener.StartListening), responseQueueUrl);

            Console.WriteLine("*");
            Console.WriteLine("Sending messages on URL: {0}", requestQueueUrl);
            Console.WriteLine("Receiving responses on URL: {0}", responseQueueUrl);
            Console.WriteLine("*");

            var messageBody = Console.ReadLine();
            while (messageBody != "x")
            {
                var parts = messageBody.Split(' ');
                if (parts[0] == "get")
                {
                    var duration = int.Parse(parts[1]);
                    var serviceRequest = new GetChangedEmployeesRequest();
                    serviceRequest.LastChangeDate = DateTime.Now.AddDays(duration).Date;
                    serviceRequest.ResponseQueueUrl = responseQueueUrl;
                    var request = new SendMessageRequest();
                    request.QueueUrl = requestQueueUrl;
                    request.RequestToBody(serviceRequest);
                    SendMessage(request, sqs, serviceRequest);
                }
                if (parts[0] == "flush")
                {
                    var serviceRequest = new FlushDataStoreRequest();
                    serviceRequest.StoreIdentifier = "Sixeyed-CloudServiceBus-ResponseData";
                    var request = new SendMessageRequest();
                    request.QueueUrl = requestQueueUrl;
                    request.RequestToBody(serviceRequest);
                    SendMessage(request, sqs, serviceRequest);
                }

                messageBody = Console.ReadLine();
            }
        }