Ejemplo n.º 1
0
 public void Process(RequestContext requestContext)
 {
     int id = Interlocked.Increment(ref this.totalCount);
     requestContext.Complete(new Message("OK" + id));
 }
Ejemplo n.º 2
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();
 }
Ejemplo n.º 3
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"));
            }
Ejemplo n.º 4
0
            void IRequestProcessor.Process(RequestContext requestContext)
            {
                Console.WriteLine("Received a request.");
                PrintMessage(requestContext.Message);

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