Пример #1
0
        public void Handle_ExampleRequest(ExampleRequest request, IDictionary<string, string> headers)
        {
            ExampleResponse response = new ExampleResponse();
            response.OriginalMessage = request.Message;
            response.ResponseMessage = string.Format("{0}, eh?  Fascinating.", request.Message);

            try
            {
                this.Log(string.Format("Responding to {0} with {1}", response.OriginalMessage, response.ResponseMessage));
                this.EventBus.RespondTo(headers, response);
            }
            catch (Exception ex)
            {
                this.Log(ex.ToString());
            }
        }
Пример #2
0
        private void _requestBtn_Click(object sender, EventArgs e)
        {
            string msg = _requestMessage.Text;

            if (string.IsNullOrEmpty(msg))
            {
                this.InformUser("Please add a request message.  Just type in whatever you like.");
                return;
            }

            ExampleRequest request = new ExampleRequest(msg);
            TimeSpan fiveSeconds = new TimeSpan(0, 0, 5);

            try
            {
                ExampleResponse response = this.EventBus.GetResponseTo<ExampleResponse>(request, fiveSeconds);

                if (null == response)
                {
                    this.Log("Did not get a response to the request within 5 seconds.  Ensure there is another .NET Consumer & Producer running");
                }
                else
                {
                    this.Log(string.Format("Got a response to '{0}': '{1}'", response.OriginalMessage, response.ResponseMessage));
                }
            }
            catch (Exception ex)
            {
                this.Log("Could not send the request: " + ex.ToString());
            }
        }