Exemplo n.º 1
0
        public void Process(MessageContext messageContext)
        {
            object body = null;
            var subject = messageContext.Message.Properties.Subject;
            switch(subject)
            {
                case "Person":
                    body = messageContext.Message.GetBody<Person>();
                    break;
                case "MapAddress":
                    body = messageContext.Message.GetBody<MapAddress>();
                    break;
                case "InternationalAddress":
                    body = messageContext.Message.GetBody<InternationalAddress>();
                    break;
                default:
                    break;
            }

            if (body == null)
            {
                Console.WriteLine("Received a message with unknown type {0} in subject.", subject);
            }
            else
            {
                Console.WriteLine("Received a message with body {0}", body.GetType().Name);
            }

            messageContext.Complete();
        }
 public override void OnMessage(MessageContext messageContext)
 {
     // this can also be done when an async operation, if required, is done
     messageContext.Complete();
 }
        public void Process(MessageContext messageContext)
        {
            if (this.Messages != null)
            {
                this.Messages.Add(messageContext.Message);
            }

            messageContext.Complete();
        }
Exemplo n.º 4
0
 void IMessageProcessor.Process(MessageContext messageContext)
 {
     messageContext.Complete();
     this.OnComplete();
 }
Exemplo n.º 5
0
 void IMessageProcessor.Process(MessageContext messageContext)
 {
     Console.WriteLine("Received a message.");
     messageContext.Complete();
 }
Exemplo n.º 6
0
 public override void OnMessage(MessageContext messageContext)
 {
     messageContext.Complete();
 }
Exemplo n.º 7
0
 public override void OnMessage(MessageContext messageContext)
 {
     this.semaphore.WaitAsync(30000).ContinueWith(
         t =>
         {
             if (!t.Result)
             {
                 messageContext.Complete(new Error() { Condition = ErrorCode.ResourceLimitExceeded });
             }
             else
             {
                 this.semaphore.Release();
                 messageContext.Complete();
             }
         });
 }
Exemplo n.º 8
0
            public override void OnMessage(MessageContext messageContext)
            {
                messageContext.Complete();

                // delay 1s for the next message
                Task.Delay(1000, this.cts.Token).ContinueWith(
                    t =>
                    {
                        if (!t.IsCanceled)
                        {
                            this.link.SetCredit(1, false, false);
                        }
                    });
            }
Exemplo n.º 9
0
 public void Process(MessageContext messageContext)
 {
     Console.WriteLine("Listener: received '{0}'.", messageContext.Message.Body);
     messageContext.Complete();
 }
Exemplo n.º 10
0
 public void Process(MessageContext messageContext)
 {
     this.Messages.Add(messageContext.Message);
     messageContext.Complete();
 }