Omicron Llama

Coding all day, every day.

Freebie: Round-Robin SPServer Selector

Here’s a nice little freebie I thought I’d share.

I have a scenario where I have a rather large batch process to run that I’ve decided to split up by creating dozens of timer jobs that process chunks of the batch, and also let me split the the job across all my SharePoint servers! You can pass an SPServer┬áreference into the constructor of SPJobDefinition and as long as you set SPJobLock to Job then the job will only run on that server.

So, I had to build a quick and dirty class that lets me select another application server in my farm each time I call it.

You instantiate it and then each time you call GetNextServer(), you’ll get a new server instance.

So here’s the full source:


, ,

Leave a Reply

Your email address will not be published. Required fields are marked *