Beispiel #1
0
        private static void CheckUserExists(DoesUserExistRequest doesUserExistRequest, msmq.Message message)
        {
            Console.WriteLine("Starting CheckUserExists for: {0}, at: {1}", doesUserExistRequest.EmailAddress, DateTime.Now.TimeOfDay);
            var doesUserExistResponse = new DoesUserExistResponse
            {
                Exists = DoesUserExist.Execute(doesUserExistRequest.EmailAddress)
            };

            using (var queue = message.ResponseQueue)
            {
                var response = new msmq.Message();
                response.BodyStream = doesUserExistResponse.ToJsonStream();
                response.Label      = doesUserExistResponse.GetMessageType();
                queue.Send(response);
            }
            Console.WriteLine("Returned: {0} for CheckUserExists for: {1}, at: {2}", doesUserExistResponse.Exists, doesUserExistRequest.EmailAddress, DateTime.Now.TimeOfDay);
        }
        private static void CheckUserExists(DoesUserExistRequest doesUserExistRequest, Message requestMessage,
                                            IMessageQueue requestQueue)
        {
            Console.WriteLine("Starting CheckUserExists for: {0}, at: {1}", doesUserExistRequest.EmailAddress,
                              DateTime.Now.TimeOfDay);
            var validator    = new UserValidator(doesUserExistRequest.EmailAddress);
            var responseBody = new DoesUserExistResponse
            {
                Exists = validator.Exists()
            };
            var responseQueue = requestQueue.GetReplyQueue(requestMessage);

            responseQueue.Send(new Message
            {
                Body = responseBody
            });
            Console.WriteLine("Returned: {0} for DoesUserExist, EmailAddress: {1}, to: {2}, at: {3}",
                              responseBody.Exists,
                              doesUserExistRequest.EmailAddress, responseQueue.Address, DateTime.Now.TimeOfDay);
        }
        public override void Handle(Message message, IMessageQueue sourceQueue)
        {
            var data = message.BodyAs <DoesUserExistRequest>();

            _logger.LogInformation($"[{DateTime.Now}] Started: {data.EmailAddress}");

            var userExists = new DoesUserExistResponse {
                Exists = DoesUserExist.Execute(data.EmailAddress)
            };
            var response = new Message {
                Body = userExists
            };

            var queue = sourceQueue.GetReplyQueue(message);

            queue.Send(response);

            _logger.LogDebug($"[{DateTime.Now}] User: {data.EmailAddress} Exists: {userExists.Exists}");
            _logger.LogInformation($"[{DateTime.Now}] Finished: {data.EmailAddress}");
        }