示例#1
0
        public MsmqQueue(Uri uri, bool isTransactional)
        {
            Guard.AgainstNull(uri, "uri");

            if (!uri.Scheme.Equals(SCHEME, StringComparison.InvariantCultureIgnoreCase))
            {
                throw new InvalidSchemeException(SCHEME, uri.ToString());
            }

            localQueueTimeout = ConfigurationItem <int> .ReadSetting("LocalQueueTimeout", 0);

            remoteQueueTimeout = ConfigurationItem <int> .ReadSetting("RemoteQueueTimeout", 2000);

            log = Log.For(this);

            var builder = new UriBuilder(uri);

            host = uri.Host;

            if (host.Equals("."))
            {
                builder.Host = Environment.MachineName.ToLower();
            }

            if (uri.LocalPath == "/")
            {
                throw new UriFormatException(string.Format(ESBResources.UriFormatException, "msmq://{{host-name}}/{{queue-name}}",
                                                           uri));
            }

            Uri = builder.Uri;

            IsLocal = Uri.Host.Equals(Environment.MachineName, StringComparison.InvariantCultureIgnoreCase);

            IsTransactional = isTransactional;
            usesIPAddress   = regexIPAddress.IsMatch(host);

            path = IsLocal
                                       ? string.Format(@"{0}\private$\{1}", host, uri.Segments[1])
                                       : usesIPAddress
                                                 ? string.Format(@"FormatName:DIRECT=TCP:{0}\private$\{1}", host, uri.Segments[1])
                                                 : string.Format(@"FormatName:DIRECT=OS:{0}\private$\{1}", host, uri.Segments[1]);

            timeout = IsLocal
                                          ? TimeSpan.FromMilliseconds(localQueueTimeout.GetValue())
                                          : TimeSpan.FromMilliseconds(remoteQueueTimeout.GetValue());
        }
示例#2
0
        public MsmqQueue(Uri uri, bool isTransactional)
        {
            Guard.AgainstNull(uri, "uri");

            if (!uri.Scheme.Equals(SCHEME, StringComparison.InvariantCultureIgnoreCase))
            {
                throw new InvalidSchemeException(SCHEME, uri.ToString());
            }

            localQueueTimeout = ConfigurationItem<int>.ReadSetting("LocalQueueTimeout", 0);
            remoteQueueTimeout = ConfigurationItem<int>.ReadSetting("RemoteQueueTimeout", 2000);

            log = Log.For(this);

            var builder = new UriBuilder(uri);

            host = uri.Host;

            if (host.Equals("."))
            {
                builder.Host = Environment.MachineName.ToLower();
            }

            if (uri.LocalPath == "/")
            {
                throw new UriFormatException(string.Format(ESBResources.UriFormatException, "memory://{{host}}/{{name}}",
                                                           Uri));
            }

            Uri = builder.Uri;

            IsLocal = Uri.Host.Equals(Environment.MachineName, StringComparison.InvariantCultureIgnoreCase);

            IsTransactional = isTransactional;
            usesIPAddress = regexIPAddress.IsMatch(host);

            path = IsLocal
                    ? string.Format(@"{0}\private$\{1}", host, uri.Segments[1])
                    : usesIPAddress
                        ? string.Format(@"FormatName:DIRECT=TCP:{0}\private$\{1}", host, uri.Segments[1])
                        : string.Format(@"FormatName:DIRECT=OS:{0}\private$\{1}", host, uri.Segments[1]);

            timeout = IsLocal
                        ? TimeSpan.FromMilliseconds(localQueueTimeout.GetValue())
                        : TimeSpan.FromMilliseconds(remoteQueueTimeout.GetValue());
        }
示例#3
0
        public RabbitMqQueue(RabbitMqConnector connector)
        {
            _connector         = connector;
            _localQueueTimeout = ConfigurationItem <int> .ReadSetting("LocalQueueTimeout", 0);

            _remoteQueueTimeout = ConfigurationItem <int> .ReadSetting("RemoteQueueTimeout", 2000);

            _log = Log.For(this);

            IsLocal         = connector.QueuePath.Host.Equals(Environment.MachineName, StringComparison.InvariantCultureIgnoreCase);
            IsTransactional = connector.QueueConfiguration.IsTransactional;

            Uri = connector.QueuePath.Uri;

            _timeout = IsLocal
                                                ? TimeSpan.FromMilliseconds(_localQueueTimeout.GetValue())
                                                : TimeSpan.FromMilliseconds(_remoteQueueTimeout.GetValue());
        }