Beispiel #1
0
        /// <summary>
        /// Unsubscribe from the specified channels.
        /// </summary>
        /// <param name="subscription">The <see cref="IRedisMessageSubscription"/> instance.</param>
        /// <param name="timeout">The timeout to wait for Redis to confirm that the unsubscribing to the specified channels is complete.</param>
        /// <param name="channels">The channels to unsubscribe from.</param>
        /// <returns>True if Redis confirmed unsubscribing to all specified channels within the specified timeout; otherwise false.</returns>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="subscription"/> is null, or <paramref name="channels"/> is null or empty array.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Parameter <paramref name="timeout"/> is less or equal to <see cref="TimeSpan.Zero"/>.</exception>
        public static bool UnsubscribeFromChannels(this IRedisMessageSubscription subscription, TimeSpan timeout, params string[] channels)
        {
            if (subscription == null)
            {
                throw new ArgumentNullException("subscription");
            }

            if ((channels == null) || (channels.Length == 0))
            {
                throw new ArgumentNullException("channels");
            }

            return(subscription.UnsubscribeFromChannels(timeout, (IEnumerable <string>)channels));
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisMessageBusReceiverBase"/> class.
        /// </summary>
        /// <param name="provider">The Redis provider to use.</param>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="provider"/> is null.</exception>
        protected RedisMessageBusReceiverBase(IRedisProvider provider)
        {
            this.debugName = this.GetType().Name;

            Trace.WriteLine("ENTER: Constructing {0} ...".FormatInvariant(this.debugName));

            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            this.provider = provider;

            this.subscription = provider.CreateSubscription();

            this.subscription.MessageReceived += this.OnMessageReceived;

            Trace.WriteLine("EXIT: {0} constructed.".FormatInvariant(this.debugName));
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisTaskProcessorMessageQueue"/> class.
        /// </summary>
        /// <param name="provider">The Redis provider to use.</param>
        /// <param name="serializer">The serializer to use for master commands serialization.</param>
        public RedisTaskProcessorMessageQueue(IRedisProvider provider, IEntityBinarySerializer serializer)
        {
            Trace.WriteLine("ENTER: Constructing {0} ...".FormatInvariant(this.debugName));

            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }

            this.provider   = provider;
            this.serializer = serializer;

            this.subscription = provider.CreateSubscription();

            this.subscription.MessageReceived += this.OnMessageReceived;

            Trace.WriteLine("EXIT: {0} constructed.".FormatInvariant(this.debugName));
        }