예제 #1
0
        public Receiver(IDictionary properties, IServerChannelSinkProvider serverSinkProvider)
        {
            // administratively setup using the config values
            // static knowledge base
            ChannelName = properties.Contains(MSMQChannelProperties.ChannelName) ?
                          Convert.ToString(properties[MSMQChannelProperties.ChannelName]) : MSMQChannelDefaults.ChannelName;
            ChannelPriority = properties.Contains(MSMQChannelProperties.ChannelPriority) ?
                              Convert.ToInt32(properties[MSMQChannelProperties.ChannelPriority]) : MSMQChannelDefaults.ChannelPriority;
            ListenerPath = properties.Contains(MSMQChannelProperties.Listener) ?
                           Convert.ToString(properties[MSMQChannelProperties.Listener]) : MSMQChannelDefaults.QueuePath;
            AllowToUpdate = properties.Contains(MSMQChannelProperties.UpdateKB) ?
                            Convert.ToBoolean(properties[MSMQChannelProperties.UpdateKB]) : MSMQChannelDefaults.CanBeUpdated;

            // dynamically knowledge base
            NotifyTime = properties.Contains(MSMQChannelProperties.NotifyTime) ?
                         Convert.ToInt32(properties[MSMQChannelProperties.NotifyTime]) : MSMQChannelDefaults.TimeoutInSec;
            RetryTime = properties.Contains(MSMQChannelProperties.RetryTime) ?
                        Convert.ToInt32(properties[MSMQChannelProperties.RetryTime]) : MSMQChannelDefaults.TimeoutInSec;
            RetryCounter = properties.Contains(MSMQChannelProperties.Retry) ?
                           Convert.ToInt32(properties[MSMQChannelProperties.Retry]) : MSMQChannelDefaults.RetryCounter;
            RetryFilter = properties.Contains(MSMQChannelProperties.RetryFilter) ?
                          Convert.ToString(properties[MSMQChannelProperties.RetryFilter]) : MSMQChannelDefaults.EmptyStr;
            NotifyUrl = properties.Contains(MSMQChannelProperties.NotifyUrl) ?
                        Convert.ToString(properties[MSMQChannelProperties.NotifyUrl]) : MSMQChannelDefaults.EmptyStr;
            AcknowledgeUrl = properties.Contains(MSMQChannelProperties.AckUrl) ?
                             Convert.ToString(properties[MSMQChannelProperties.AckUrl]) : MSMQChannelDefaults.EmptyStr;
            ExceptionUrl = properties.Contains(MSMQChannelProperties.ExceptionUrl) ?
                           Convert.ToString(properties[MSMQChannelProperties.ExceptionUrl]) : MSMQChannelDefaults.EmptyStr;
            UseTimeout = properties.Contains(MSMQChannelProperties.UseTimeout) ?
                         Convert.ToBoolean(properties[MSMQChannelProperties.UseTimeout]) : MSMQChannelDefaults.UseTimeout;
            // validate number of threads
            MaxNumberOfWorkers = MSMQChannelDefaults.MaxThreads;
            if (properties.Contains(MSMQChannelProperties.MaxThreads))
            {
                string maxthreads = Convert.ToString(properties[MSMQChannelProperties.MaxThreads]);
                Update(MSMQChannelProperties.MaxThreads, maxthreads);
            }

            // channel provider
            m_Provider = serverSinkProvider == null ? new BinaryServerFormatterSinkProvider() : serverSinkProvider;

            /*
             * // Collect the rest of the channel data:
             * IServerChannelSinkProvider provider = m_Provider;
             * while(provider != null)
             * {
             *      provider.GetChannelData(_data);
             *      provider = provider.Next;
             * }
             */

            IServerChannelSink next = ChannelServices.CreateServerChannelSinkChain(m_Provider, this);

            m_Sink = new MSMQServerTransportSink(next);

            // publish the MSMQChannel endpoint using the channel name.
            base.Publish(ChannelName);

            // start Listener
            StartListening(null);
        }
예제 #2
0
파일: Receiver.cs 프로젝트: yallie/zyan
		public Receiver(IDictionary properties, IServerChannelSinkProvider serverSinkProvider) 
		{	
			// administratively setup using the config values
			// static knowledge base
			ChannelName = properties.Contains(MSMQChannelProperties.ChannelName) ? 
				Convert.ToString(properties[MSMQChannelProperties.ChannelName]) : MSMQChannelDefaults.ChannelName;
			ChannelPriority = properties.Contains(MSMQChannelProperties.ChannelPriority) ? 
				Convert.ToInt32(properties[MSMQChannelProperties.ChannelPriority]) : MSMQChannelDefaults.ChannelPriority;
			ListenerPath = properties.Contains(MSMQChannelProperties.Listener) ? 
				Convert.ToString(properties[MSMQChannelProperties.Listener]) : MSMQChannelDefaults.QueuePath;
			AllowToUpdate = properties.Contains(MSMQChannelProperties.UpdateKB) ? 
				Convert.ToBoolean(properties[MSMQChannelProperties.UpdateKB]) : MSMQChannelDefaults.CanBeUpdated;
			
			// dynamically knowledge base
			NotifyTime = properties.Contains(MSMQChannelProperties.NotifyTime) ? 
				Convert.ToInt32(properties[MSMQChannelProperties.NotifyTime]) : MSMQChannelDefaults.TimeoutInSec;
			RetryTime = properties.Contains(MSMQChannelProperties.RetryTime) ?
				Convert.ToInt32(properties[MSMQChannelProperties.RetryTime]) : MSMQChannelDefaults.TimeoutInSec;
			RetryCounter = properties.Contains(MSMQChannelProperties.Retry) ? 
				Convert.ToInt32(properties[MSMQChannelProperties.Retry]) : MSMQChannelDefaults.RetryCounter;
			RetryFilter = properties.Contains(MSMQChannelProperties.RetryFilter) ? 
				Convert.ToString(properties[MSMQChannelProperties.RetryFilter]) : MSMQChannelDefaults.EmptyStr;
			NotifyUrl = properties.Contains(MSMQChannelProperties.NotifyUrl) ? 
				Convert.ToString(properties[MSMQChannelProperties.NotifyUrl]) : MSMQChannelDefaults.EmptyStr;
			AcknowledgeUrl = properties.Contains(MSMQChannelProperties.AckUrl) ? 
				Convert.ToString(properties[MSMQChannelProperties.AckUrl]) : MSMQChannelDefaults.EmptyStr;
			ExceptionUrl = properties.Contains(MSMQChannelProperties.ExceptionUrl) ? 
				Convert.ToString(properties[MSMQChannelProperties.ExceptionUrl]) : MSMQChannelDefaults.EmptyStr;
			UseTimeout = properties.Contains(MSMQChannelProperties.UseTimeout) ? 
				Convert.ToBoolean(properties[MSMQChannelProperties.UseTimeout]) : MSMQChannelDefaults.UseTimeout;
			// validate number of threads
			MaxNumberOfWorkers = MSMQChannelDefaults.MaxThreads;
			if(properties.Contains(MSMQChannelProperties.MaxThreads)) 
			{
				string maxthreads = Convert.ToString(properties[MSMQChannelProperties.MaxThreads]);
				Update(MSMQChannelProperties.MaxThreads, maxthreads);
			}
					
			// channel provider
			m_Provider = serverSinkProvider == null ? new BinaryServerFormatterSinkProvider() : serverSinkProvider;

			/*
			// Collect the rest of the channel data:
			IServerChannelSinkProvider provider = m_Provider;
			while(provider != null)
			{
				provider.GetChannelData(_data);
				provider = provider.Next;
			}
			*/
		
			IServerChannelSink next = ChannelServices.CreateServerChannelSinkChain(m_Provider, this);
			m_Sink = new MSMQServerTransportSink(next);

			// publish the MSMQChannel endpoint using the channel name.
			base.Publish(ChannelName);

			// start Listener
			StartListening(null);
		}