Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of JobExecutionContext.
        /// </summary>
        /// <param name="serviceProvider">
        /// The IServiceProvider to use.
        /// </param>
        private JobExecutionContext(IServiceProvider serviceProvider)
        {
            Debug.Assert(null != serviceProvider, "The serviceProvider must not be null.");
            this.serviceProvider = serviceProvider;

            queue = serviceProvider.GetService <CloudQueue>();
            Debug.Assert(null != queue, "The queue must not be null.");

            factory = serviceProvider.GetService <JobFactory>();
            Debug.Assert(null != factory, "The factory must not be null.");

            consumerSettings = serviceProvider.GetService <ConsumerSettings>();
            Debug.Assert(null != consumerSettings, "The consumer settings must not be null.");

            jobDescriptor = new Lazy <JobDescriptor>(GetJobDescriptor);
            job           = new Lazy <IJob>(GetJob);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of Producer using the given connectionSettings to connect to the Queue.
        /// </summary>
        /// <param name="connectionSettings">
        /// The ConnectionSettings which define the Storage Account and Queue to use.
        /// </param>
        /// <param name="factory">
        /// The JobFactory to use to serialize instances of IJob.
        /// </param>
        public Producer(ConnectionSettings connectionSettings, JobFactory factory)
        {
            if (null == connectionSettings)
            {
                throw new ArgumentNullException("connectionSettings");
            }
            else if (null == factory)
            {
                throw new ArgumentNullException("factory");
            }

            queue = connectionSettings.GetQueue();
            queue.CreateIfNotExistsAsync().GetAwaiter().GetResult();

            this.connectionSettings = connectionSettings;
            this.factory            = factory;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of Producer using the given connectionSettings to connect to the Queue.
        /// </summary>
        /// <param name="connectionSettings">
        /// The ConnectionSettings which define the Storage Account and Queue to use.
        /// </param>
        /// <param name="factory">
        /// The JobFactory to use to serialize instances of IJob.
        /// </param>
        public Producer(ConnectionSettings connectionSettings, JobFactory factory)
        {
            if (null == connectionSettings)
            {
                throw new ArgumentNullException("connectionSettings");
            }
            else if (null == factory)
            {
                throw new ArgumentNullException("factory");
            }

            queue = connectionSettings.GetQueue();
            queue.CreateIfNotExists();

            this.connectionSettings = connectionSettings;
            this.factory = factory;
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of Consumer using the given connectionSettings to connect to the Queue.
        /// </summary>
        /// <param name="connectionSettings">
        /// The ConnectionSettings which define the Storage Account and Queue to use.
        /// </param>
        /// <param name="factory">
        /// The JobFactory to use to create instances of IJob.
        /// </param>
        /// <param name="settings">
        /// The ConsumerSettings to use. If null, the default ConsumerSettings will be used.
        /// </param>
        public Consumer(ConnectionSettings connectionSettings, JobFactory factory, ConsumerSettings settings)
        {
            if (null == connectionSettings)
            {
                throw new ArgumentNullException("connectionSettings");
            }
            else if (null == factory)
            {
                throw new ArgumentNullException("factory");
            }

            queue = connectionSettings.GetQueue();
            queue.CreateIfNotExists();

            this.connectionSettings = connectionSettings;
            this.factory = factory;
            this.consumerSettings = settings ?? ConsumerSettings.CreateDefault();
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of Consumer using the given connectionSettings to connect to the Queue, and
 /// using the default ConsumerSettings.
 /// </summary>
 /// <param name="connectionSettings">
 /// The ConnectionSettings which define the Azure Storage Account and Queue to use.
 /// </param>
 /// <param name="factory">
 /// The JobFactory to use to create instances of IJob.
 /// </param>
 public Consumer(ConnectionSettings connectionSettings, JobFactory factory)
     : this(connectionSettings, factory, ConsumerSettings.CreateDefault())
 {
 }
Beispiel #6
0
        /// <summary>
        /// Initializes a new instance of JobExecutionContext.
        /// </summary>
        /// <param name="serviceProvider">
        /// The IServiceProvider to use.
        /// </param>
        private JobExecutionContext(IServiceProvider serviceProvider)
        {
            Debug.Assert(null != serviceProvider, "The serviceProvider must not be null.");
            this.serviceProvider = serviceProvider;

            queue = serviceProvider.GetService<CloudQueue>();
            Debug.Assert(null != queue, "The queue must not be null.");

            factory = serviceProvider.GetService<JobFactory>();
            Debug.Assert(null != factory, "The factory must not be null.");

            consumerSettings = serviceProvider.GetService<ConsumerSettings>();
            Debug.Assert(null != consumerSettings, "The consumer settings must not be null.");

            job = new Lazy<IJob>(GetJob);
        }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of Consumer using the given connectionSettings to connect to the Queue, and
 /// using the default ConsumerSettings.
 /// </summary>
 /// <param name="connectionSettings">
 /// The ConnectionSettings which define the Azure Storage Account and Queue to use.
 /// </param>
 /// <param name="factory">
 /// The JobFactory to use to create instances of IJob.
 /// </param>
 public Consumer(ConnectionSettings connectionSettings, JobFactory factory)
     : this(connectionSettings, factory, ConsumerSettings.CreateDefault())
 {
 }