Beispiel #1
0
            async Task ReplyAsync(RequestContext requestContext)
            {
                if (this.offset == 0)
                {
                    this.offset = (int)requestContext.Message.ApplicationProperties["offset"];
                }

                while (this.offset < 1000)
                {
                    try
                    {
                        Message response = new Message("reply" + this.offset);
                        response.ApplicationProperties = new ApplicationProperties();
                        response.ApplicationProperties["offset"] = this.offset;
                        requestContext.ResponseLink.SendMessage(response);
                        this.offset++;
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine("Exception: " + exception.Message);
                        if (requestContext.State == ContextState.Aborted)
                        {
                            Console.WriteLine("Request is aborted. Last offset: " + this.offset);
                            return;
                        }
                    }

                    await Task.Delay(1000);
                }

                requestContext.Complete(new Message("done"));
            }
 public void Process(RequestContext requestContext)
 {
     int id = Interlocked.Increment(ref this.totalCount);
     requestContext.Complete(new Message("OK" + id));
 }
Beispiel #3
0
 void IRequestProcessor.Process(RequestContext requestContext)
 {
     Message response = new Message("request processed");
     response.ApplicationProperties = new ApplicationProperties();
     response.ApplicationProperties["status-code"] = 200;
     requestContext.Complete(response);
     this.OnComplete();
 }
Beispiel #4
0
 void IRequestProcessor.Process(RequestContext requestContext)
 {
     Console.WriteLine("Received a request " + requestContext.Message.Body);
     var task = this.ReplyAsync(requestContext);
 }
Beispiel #5
0
            void IRequestProcessor.Process(RequestContext requestContext)
            {
                Console.WriteLine("Received a request.");
                PrintMessage(requestContext.Message);

                Message response = new Message("welcome");
                requestContext.Complete(response);
            }