Configuration & Setup
This section will explain some of the less obvious sections of the service configuration. (BackroundWorkerService.Service/app.config)
As you can see, it is commented already for the most part, I will just highlight some pieces.
Configure JobStore
- First off, by default the service uses the RAMJobstore. This means job data will be stored in memory, and every time the service is restarted, all this information is lost. So lets go ahead and change this to use the SQL job store.
- First find the file "BackgroundWorkerService.Logic\BackgroundWorkerJobs.sql" and run the sql script into a SQL database of your choosing.
- Uncomment this line :
<section name="BackgroundWorkerService.Logic.Configuration.Linq2SqlJobStoreConfigurationSection" type="BackgroundWorkerService.Logic.Configuration.Linq2SqlJobStoreConfigurationSection, BackgroundWorkerService.Logic"/>
- Comment out this line (not needed since we're not using the RamJobStore) :
<section name="BackgroundWorkerService.Logic.Configuration.RamJobStoreConfigurationSection" type="BackgroundWorkerService.Logic.Configuration.RamJobStoreConfigurationSection, BackgroundWorkerService.Logic" />
- Uncomment this line (tells the service not to use the default Ramjob store, but rather the linq2sqljobstore) :
<JobStore type="BackgroundWorkerService.Logic.Implementation.JobStore.Linq2Sql.Linq2SqlJobStore, BackgroundWorkerService.Logic" settingsProviderType="BackgroundWorkerService.Logic.Implementation.Internal.Providers.Linq2SqlSettingsProvider, BackgroundWorkerService.Logic" />
<JobStore type="BackgroundWorkerService.Logic.Implementation.JobStore.RamJobStore, BackgroundWorkerService.Logic" settingsProviderType="BackgroundWorkerService.Logic.Implementation.Internal.Providers.ConfigRamJobsStoreSettingsProvider, BackgroundWorkerService.Logic" />
- Uncomment this line (tells the service what the name of the connectionstring is) :
<BackgroundWorkerService.Logic.Configuration.Linq2SqlJobStoreConfigurationSection connectionStringName="BackgroundWorkerConnectionString" />
- Change the connectionstring (named "BackgroundWorkerConnectionString"), to point to your new database
- Now look at the main config section (you won't really have to change anything here) :
<BackgroundWorkerService.Logic.Implementation.Internal.Providers.Configuration.ConfigSettingsProvider PollFrequency="00:00:01.000" ShutdownTimeout="00:01:00" InstanceName="">
<JobStore type="BackgroundWorkerService.Logic.Implementation.JobStore.RamJobStore, BackgroundWorkerService.Logic" settingsProviderType="BackgroundWorkerService.Logic.Implementation.Internal.Providers.ConfigRamJobsStoreSettingsProvider, BackgroundWorkerService.Logic" />
<Queues>
<Queue Id="0" ThreadCount="50" type="BackgroundWorkerService.Logic.Implementation.Internal.ThreadExecutionQueue, BackgroundWorkerService.Logic" />
<Queue Id="1" ThreadCount="20" type="BackgroundWorkerService.Logic.Implementation.Internal.ThreadPoolExecutionQueue, BackgroundWorkerService.Logic" />
<Queue Id="2" ThreadCount="50" type="BackgroundWorkerService.Logic.Implementation.Internal.TimedThreadExecutionQueue, BackgroundWorkerService.Logic" />
</Queues>
</BackgroundWorkerService.Logic.Implementation.Internal.Providers.Configuration.ConfigSettingsProvider>
- PollFrequency : This determines how often the database is polled to look if there are any new jobs or scheduled jobs that require execution. It also affects the timing resolution of scheduled jobs (for obvious reasons).
- ShutdownTimeout : How long the service can wait before forcing jobs to die. Set to higher than your longest running job.
- InstanceName : Set this if you want to name the worker service instance (defaults to machine name if null or empty)
- The Queue Ids are hard coded in the UI so if you change them, you'll have to change the html in the UI as well.
Execution Queues (ThreadPools)
- You shouldn't need to do too much here, except ensure the limits are set on the ThreadCount properties.
- I'd recommend leaving the queues as they are, but if you need some kind of high priority (or low priority queue for that matter), it's simple to add more. You can have up to 256 queues, which would be kind of insane though.
- In practice, I've never seen the system have a problem with a threadcount of thousands, but it depends on how heavy your job processing is.
Web User InterfaceThe built in web ui is configured with this section :
<BackgroundWorkerService.Service.Configuration.WebServerConfiguration Enabled="true" />
- You'll find the other settings (which all defaults) in BackgroundWorkerService.Service.Configuration.WebServerConfiguration
- To change for instance the security around the web interface is simple, since it's just an asp.net website (so you can stick forms auth/windows auth/permissions whatever in the web.config)
WCF Admin Service
- Exposing the service via WCF is also easily configured in the system.serviceModel section. I'm not going to go into WCF configuration, but it's all standard stuff (security, https etc.)
Setup PackageThe last step when running the installer shows you some additional steps that are required, mostly only the first time you install on a server. FOLLOW these steps.