Beispiel #1
0
        /// <summary>
        /// Creates a new instance of the queue host using the given parameters.
        /// </summary>
        /// <param name="hostName">Name/address of machine where queue will be hosted.</param>
        /// <param name="port">TCP port that queue will listen on.</param>
        /// <param name="baseAddress">Base address, if any (will be part of the queue address).</param>
        /// <param name="catalogLocation">File name where the queue metadata is stored.</param>
        /// <param name="persistLocation">Folder where messages are persisted.</param>
        /// <param name="transitLocation">
        /// Folder where messages are temporarily kept 
        /// during dequeue until committed.
        /// </param>
        /// <param name="transitCleanupInterval">
        /// Period in milliseconds used to scan and 
        /// cleanup (i.e. re-queue) uncommitted messages.
        /// </param>
        /// <param name="transitMaximumAge">
        /// For uncommitted messages, the maximum number of 
        /// milliseconds they stay that way before being cleaned up (i.e. re-queued).
        /// </param>
        public QueueHost(string hostName, int port, string baseAddress, string catalogLocation,
                         string persistLocation, string transitLocation, int transitCleanupInterval,
                         int transitMaximumAge)
        {
            QueueManager.Initialize(catalogLocation, persistLocation,
                                    transitLocation, transitCleanupInterval, transitMaximumAge);

            var queueAddressBuilder = new AddressBuilder
            {
                HostName = hostName,
                Port = port,
                BaseAddress = baseAddress + "/Queue.svc"
            };

            var queueAdminAddressBuilder = new AddressBuilder
            {
                HostName = hostName,
                Port = port,
                BaseAddress = baseAddress + "/QueueAdmin.svc"
            };

            var queueAddress = queueAddressBuilder.BuildAddress();
            var queueAdminAddress = queueAdminAddressBuilder.BuildAddress();

            try
            {
                this.QueueServiceHost = new ServiceHost(typeof (QueueService));
                this.QueueAdminServiceHost = new ServiceHost(typeof (QueueAdminService));

                this.QueueServiceHost.AddServiceEndpoint(typeof (IQueueService), new NetTcpBinding(), queueAddress);
                this.QueueAdminServiceHost.AddServiceEndpoint(typeof (IQueueAdminService),
                                                              new NetTcpBinding(), queueAdminAddress);

                foreach (var serviceMetadataBehavior in new[] {this.QueueServiceHost, this.QueueAdminServiceHost}
                    .Select(x => x.Description.Behaviors.Find<ServiceMetadataBehavior>())
                    .Where(x => x != null))
                {
                    serviceMetadataBehavior.HttpGetEnabled = false;
                    serviceMetadataBehavior.HttpsGetEnabled = false;
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);

                throw new FaultException<QueueErrorInfo>(
                    QueueErrorInfo.FromErrorCode(QueueErrorCode.ServerHostInitializationFailed));
            }
        }
Beispiel #2
0
        public QueueConnection(string hostName, int port, string baseAddress)
        {
            var queueAdminAddressBuilder = new AddressBuilder
            {
                HostName = hostName,
                Port = port,
                BaseAddress = baseAddress + "/QueueAdmin.svc"
            };

            var queueAddressBuilder = new AddressBuilder
            {
                HostName = hostName,
                Port = port,
                BaseAddress = baseAddress + "/Queue.svc"
            };

            this.queueAdminAddress = queueAdminAddressBuilder.BuildAddress();
            this.queueAddress = queueAddressBuilder.BuildAddress();
        }