Shaul Behr
Shaul Behr

Reputation: 38091

Octopus - deploying multiple copies of same service

I've got an Octopus deployment for an NServiceBus consumer. Until recently, there's only been one queue to consume. Now we're trying to get smart about putting different types of messages in different queues. Right now we've broken that up into 3 queues, but that number might increase in the future.

The plan now is to install the NSB consumer service 3 times, in 3 separate folders, under 3 different names. The only difference in the 3 deployments will be an app.config setting:

<add key="NsbConsumeQueue" value="RedQueue" />

So we'll have a Red service, a Green service and a Blue service, and each one will be configured to consume the appropriate queue.

What's the best way to deploy these 3 services in Octopus? My ideal would be to declare some kind of list of services somewhere e.g.

ServiceName    QueueName
-----------    ---------
RedService     RedQueue
GreenService   GreenQueue
BlueService    BlueQueue

and loop through those services, deploying each one in its own folder, and substituting the value of NsbConsumeQueue in app.config to the appropriate value. I don't think this can be done using variables, which leaves PowerShell.

Any idea how to write a PS script that would do this?

Upvotes: 0

Views: 1274

Answers (2)

tspauld
tspauld

Reputation: 3522

Powershell should not be needed for this. Variables in Octopus can be scoped to a step in the deployment process. So you could have 3 steps, one for each service, and 3 variables for the queue names, each scoped to one of the steps.

You could also add variables for the service names, and use those variables in the process step settings. That would let you see both the service names and queue names from the variables page.

Upvotes: 1

Dennis van der Stelt
Dennis van der Stelt

Reputation: 2178

At my previous employer, we used the following script to deploy from Octopus: http://www.layerstack.net/blog/posts/deploying-nservicebus-with-octopus-deploy

Add the two Powershell scripts to your project that contains the NServiceBus host. Be sure to override the host identifier or ServicePulse will go mad, because every deployment gets its own folder, due to Octopus.

But as mentioned in the comments, be sure that you're splitting endpoints for the right reason. We also had/have at least 4 services, but that's because we have a logical separation. For example, we have a finance service where all finance messages go to. And a sales service where all sales services go to. This follows the DDD bounded context principle and is there for reasons. I hope your services aren't actually called red, green and blue! :)

Upvotes: 1

Related Questions