Ejemplo n.º 1
0
        public static SqlServerStorage UseActiveMq(this SqlServerStorage storage, string activeMqUri, QueueStorageOptions options, params string[] queues)
        {
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }
            if (queues == null)
            {
                throw new ArgumentNullException("queues");
            }
            if (queues.Length == 0)
            {
                throw new ArgumentException("No queue(s) specified for RabbitMQ provider.", "queues");
            }
            if (string.IsNullOrEmpty(activeMqUri))
            {
                throw new ArgumentNullException("activeMqUri is null");
            }

            if (options == null)
            {
                options = new QueueStorageOptions();
            }

            var         factory = new Apache.NMS.ActiveMQ.ConnectionFactory(activeMqUri);
            IConnection client  = factory.CreateConnection();

            var provider = new QueueStorageJobQueueProvider(client, options, queues);

            storage.QueueProviders.Add(provider, queues);

            return(storage);
        }
        //private static readonly Hangfire.Logging.ILog Logger = Hangfire.Logging.LogProvider.For<RabbitMqJobQueue>();

        public QueueStorageJobQueue(IConnection client, QueueStorageOptions options)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            _client  = client;
            _options = options;
        }
        public QueueStorageJobQueueProvider(
            IConnection client,
            QueueStorageOptions options,
            string[] queues)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            if (queues == null)
            {
                throw new ArgumentNullException("queues");
            }

            _client  = client;
            _options = options;
            _queues  = queues;

            CreateQueuesIfNotExists();
        }