Exemplo n.º 1
0
        /// <summary>
        /// Sends the query message to the named service instance and waits for
        /// a reply.
        /// </summary>
        /// <param name="serviceName">The service name.</param>
        /// <param name="query">The query message.</param>
        /// <returns>The reply message.</returns>
        /// <remarks>
        /// Throws a TimeoutException if the service doesn't respond by MaxWaitTime.
        /// </remarks>
        private ServiceMsg Query(string serviceName, ServiceMsg query)
        {
            using (TimedLock.Lock(this))
            {
                refID       = Helper.NewGuid();
                query.RefID = refID;
            }

            query["Reply-To"] = ControlMemPrefix + id.ToString();

            outbox.Send(ServiceMemPrefix + serviceName, query.ToBytes());
            if (!onReply.WaitOne(MaxWaitTime, false))
            {
                throw new System.TimeoutException();
            }

            if (reply.Command != "Ack")
            {
                throw new InvalidOperationException("Invalid Service response.");
            }

            return(reply);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Sends a reply to the query passed.
 /// </summary>
 /// <param name="query">The query message received.</param>
 /// <param name="ack">The reply.</param>
 private void ReplyTo(ServiceMsg query, ServiceMsg ack)
 {
     ack.RefID = query.RefID;
     outbox.Send(query["Reply-To"], ack.ToBytes());
 }