/// <summary>
        /// Sends the <paramref name="message"/> to the <see cref="ServiceBusService"/> for distribution amongst its registered consumers.
        /// </summary>
        /// <param name="message">The <see cref="Message"/> that is to be distributed.</param>
        public virtual void Publish(Message message)
        {
            // Retrieve publisher information.
            ClientInfo client = null;
            if (OperationContext.Current != null)
            {
                m_clientsLock.EnterReadLock();
                try
                {
                    // Update statistics data.
                    if (m_clients.TryGetValue(OperationContext.Current.SessionId, out client))
                        Interlocked.Increment(ref client.MessagesProduced);
                }
                finally
                {
                    m_clientsLock.ExitReadLock();
                }
            }

            // Retrieve registration information.
            RegistrationInfo registration = null;
            if (message.Type == MessageType.Queue)
            {
                // Queue
                m_queuesLock.EnterReadLock();
                try
                {
                    m_queues.TryGetValue(message.Name, out registration);
                }
                finally
                {
                    m_queuesLock.ExitReadLock();
                }
            }
            else if (message.Type == MessageType.Topic)
            {
                // Topic
                m_topicsLock.EnterReadLock();
                try
                {
                    m_topics.TryGetValue(message.Name, out registration);
                }
                finally
                {
                    m_topicsLock.ExitReadLock();
                }
            }
            else
            {
                // Unsupported
                throw new NotSupportedException(string.Format("Message type '{0}' is not supported by this operation", message.Type));
            }

            // Queue message for distribution.
            if (registration != null && m_publishQueue != null)
            {
                Interlocked.Increment(ref registration.MessagesReceived);
                m_publishQueue.Add(new PublishContext(message, registration));
            }
        }
 public PublishContext(Message message, RegistrationInfo registration)
 {
     Message = message;
     Registration = registration;
 }