コード例 #1
0
        private bool open;                                      // True if no reply has been sent yet

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="msgRequestContext">The underlying LillTek Messaging <see cref="MsgRequestContext" />.</param>
        /// <param name="request">The WCF request <see cref="Message" />.</param>
        /// <param name="implementation">The concrete reply <see cref="IReplyImplementation" />.</param>
        public LillTekRequestContext(MsgRequestContext msgRequestContext, Message request, IReplyImplementation implementation)
            : base()
        {
            this.msgRequestContext = msgRequestContext;
            this.request           = request;
            this.implementation    = implementation;
            this.open = true;
        }
コード例 #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">The decoded WCF message.</param>
 /// <param name="context">The LillTek Messaging <see cref="MsgRequestContext" />.</param>
 /// <param name="ttd">The request time-to-die (SYS) while still queued.</param>
 public RequestInfo(Message message, MsgRequestContext context, DateTime ttd)
 {
     this.Message = message;
     this.Context = context;
     this.TTD     = ttd;
 }
コード例 #3
0
        private static void DoAction(MsgRouter router, BaseMsg msg)
        {
            TestAck ack;

            try
            {
                switch (msg.Action)
                {
                case "Normal":

                    router.ReplyTo(msg, new TestAck(msg.Value));
                    break;

                case "Normal-RequestContext":

                    using (MsgRequestContext ctx = msg.CreateRequestContext())
                        ctx.Reply(new TestAck(msg.Value));

                    break;

                case "Normal-Orphan-RequestContext":

                    msg.CreateRequestContext();
                    break;

                case "Exception":

                    ack           = new TestAck();
                    ack.Exception = msg.Value;

                    router.ReplyTo(msg, ack);
                    break;

                case "Ignore":

                    break;

                case "ActionCount":

                    ack = new TestAck();

                    lock (syncLock)
                        ack.Value = msg.Value + ": " + actionCount.ToString();

                    router.ReplyTo(msg, ack);
                    break;

                case "Throw-Exception":

                    Assert.Fail(msg.Value);
                    break;

                case "Sleep":

                    Thread.Sleep(TimeSpan.FromSeconds(router.SessionTimeout.TotalSeconds + 5));
                    router.ReplyTo(msg, new TestAck("Hello World!"));
                    break;

                default:

                    throw new InvalidOperationException("Unexpected action.");
                }
            }
            finally
            {
                lock (syncLock)
                    actionCount++;
            }
        }