Skip to content

Commit

Permalink
Changes to the configuration and hosting story for azure - part 1
Browse files Browse the repository at this point in the history
AsA_Worker (replaces AsA_Server and AsA_publisher)
Added Development Profile
AsA_Host will load assemblies from blob storage as a zip and start running them in a specific azure generic host process (very immature version)
  • Loading branch information
yvesgoeleven committed Aug 19, 2011
1 parent 24469ed commit 1da570a
Show file tree
Hide file tree
Showing 47 changed files with 1,159 additions and 245 deletions.
Binary file modified Samples/AzureFullDuplex/AzureFullDuplex.suo
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

namespace OrderService
{
public class EndpointConfiguration : IConfigureThisEndpoint, AsA_Server { }
public class EndpointConfiguration : IConfigureThisEndpoint, AsA_Worker { }
}
1 change: 1 addition & 0 deletions Samples/AzureFullDuplex/ServiceConfiguration.cscfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ConfigurationSettings>
<Setting name="AzureQueueConfig.ConnectionString" value="UseDevelopmentStorage=true"/>
<!--<Setting name="AzureQueueConfig.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName={your account name};AccountKey={your account key}"/>-->
<Setting name="AzureSubscriptionStorageConfig.ConnectionString" value="UseDevelopmentStorage=true" />
<Setting name="NServiceBus.Profile" value="NServiceBus.Production" />
<Setting name="Diagnostics.Level" value="Error" />
<Setting name="Diagnostics.ConnectionString" value="UseDevelopmentStorage=true"/>
Expand Down
1 change: 1 addition & 0 deletions Samples/AzureFullDuplex/ServiceDefinition.csdef
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<WorkerRole name="OrderService" enableNativeCodeExecution="true">
<ConfigurationSettings>
<Setting name="AzureQueueConfig.ConnectionString" />
<Setting name="AzureSubscriptionStorageConfig.ConnectionString" />
<Setting name="NServiceBus.Profile" />
<Setting name="Diagnostics.ConnectionString" />
<Setting name="Diagnostics.Level" />
Expand Down
2 changes: 1 addition & 1 deletion Samples/AzurePubSub/OrderService/EndpointConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

namespace OrderService
{
public class EndpointConfiguration : IConfigureThisEndpoint, AsA_Publisher { }
public class EndpointConfiguration : IConfigureThisEndpoint, AsA_Worker { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace OrderService
{
public class EndpointConfiguration : IConfigureThisEndpoint, AsA_Publisher
public class EndpointConfiguration : IConfigureThisEndpoint, AsA_Worker
{

}
Expand Down
1 change: 1 addition & 0 deletions Samples/AzureThumbnailCreator/ServiceConfiguration.cscfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<Instances count="1" />
<ConfigurationSettings>
<Setting name="AzureQueueConfig.ConnectionString" value="UseDevelopmentStorage=true" />
<Setting name="AzureSubscriptionStorageConfig.ConnectionString" value="UseDevelopmentStorage=true" />
<Setting name="AzureDatabusConfig.ConnectionString" value="UseDevelopmentStorage=true" />
<Setting name="NServiceBus.Profile" value="NServiceBus.Production" />
<Setting name="Diagnostics.Level" value="Error" />
Expand Down
3 changes: 1 addition & 2 deletions Samples/AzureThumbnailCreator/ServiceDefinition.build.csdef
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<Setting name="UnicastBusConfig.LocalAddress" />
<Setting name="MsmqTransportConfig.NumberOfWorkerThreads" />
<Setting name="MsmqTransportConfig.MaxRetries" />
<Setting name="CloudToolsDiagnosticAgentVersion" />
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="HttpIn" protocol="http" port="80" />
Expand All @@ -36,6 +35,7 @@
<WorkerRole name="Service" enableNativeCodeExecution="true">
<ConfigurationSettings>
<Setting name="AzureQueueConfig.ConnectionString" />
<Setting name="AzureSubscriptionStorageConfig.ConnectionString" />
<Setting name="AzureDatabusConfig.ConnectionString" />
<Setting name="NServiceBus.Profile" />
<Setting name="Diagnostics.ConnectionString" />
Expand All @@ -45,7 +45,6 @@
<Setting name="MsmqTransportConfig.NumberOfWorkerThreads" />
<Setting name="MsmqTransportConfig.MaxRetries" />
<Setting name="ThumbNailStore.ConnectionString" />
<Setting name="CloudToolsDiagnosticAgentVersion" />
</ConfigurationSettings>
</WorkerRole>
</ServiceDefinition>
1 change: 1 addition & 0 deletions Samples/AzureThumbnailCreator/ServiceDefinition.csdef
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<WorkerRole name="Service" enableNativeCodeExecution="true">
<ConfigurationSettings>
<Setting name="AzureQueueConfig.ConnectionString" />
<Setting name="AzureSubscriptionStorageConfig.ConnectionString" />
<Setting name="AzureDatabusConfig.ConnectionString" />
<Setting name="NServiceBus.Profile" />
<Setting name="Diagnostics.ConnectionString" />
Expand Down
Binary file modified Samples/GenericHost/GenericHost.suo
Binary file not shown.
Binary file added lib/Ionic.Zip.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ private void ConfigureThreshold()

private void ConfigureAzureDiagnostics()
{
if (!RoleEnvironment.IsAvailable) return;

Trace.Listeners.Add(new DiagnosticMonitorTraceListener());

var cloudStorageAccount = CloudStorageAccount.Parse(GetConnectionString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ T IConfigurationSource.GetConfiguration<T>()
var sectionName = typeof(T).Name;

var section = GetConfigurationHandler()
.GetSection(sectionName) as T ?? new T();
.GetSection(sectionName) as T;

foreach (var property in typeof(T).GetProperties().Where(x => x.DeclaringType == typeof(T)))
{
var setting = azureConfigurationSettings.GetSetting(sectionName + "." + property.Name);

if (!string.IsNullOrEmpty(setting))
{
if( section == null) section = new T();

property.SetValue(section, Convert.ChangeType(setting, property.PropertyType), null);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Linq;
using Topshelf.Internal;
using Topshelf.Internal.ArgumentParsing;

namespace NServiceBus.Hosting.Azure.HostProcess
{
internal class HostArguments
{
public HostArguments(Parser.Args arguments)
{
Help = GetArgument(arguments, "help") ?? GetArgument(arguments, "?");
ServiceName = GetArgument(arguments, "serviceName");
DisplayName = GetArgument(arguments, "displayName");
Description = GetArgument(arguments, "description");
EndpointConfigurationType = GetArgument(arguments, "endpointConfigurationType");
DependsOn = GetArgument(arguments, "dependsOn");
StartManually = GetArgument(arguments, "startManually");
Username = GetArgument(arguments, "username");
Password = GetArgument(arguments, "password");
}

public IArgument Help { get; set; }
public IArgument ServiceName { get; set; }
public IArgument DisplayName { get; set; }
public IArgument Description { get; set; }
public IArgument EndpointConfigurationType { get; set; }
public IArgument DependsOn { get; set; }
public IArgument StartManually { get; set; }
public IArgument Username { get; set; }
public IArgument Password { get; set; }

private static IArgument GetArgument(Parser.Args arguments, string key)
{
IArgument argument = arguments.CustomArguments.Where(x => x.Key != null).SingleOrDefault(x => x.Key.ToUpper() == key.ToUpper());

if (argument != null)
{
arguments.CustomArguments = arguments.CustomArguments.Except(new[] {argument});
}

return argument;
}
}
}
54 changes: 54 additions & 0 deletions src/hosting/NServiceBus.Hosting.Azure.HostProcess/Content/Help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
NServiceBus Message Endpoint Host Service

USAGE:
NServiceBus.Hosting.Azure.HostProcess.exe [/install [/serviceName]
[/displayName]
[/description]
[/endpointConfigurationType]
[/instance]
[/startManually]
[/username]
[/password]] |
[/uninstall[/serviceName]
[/instance]]

OPTIONS:

/install Install the message endpoint as a Windows service
/serviceName Specify the service name for the installed service
/displayName Friendly name for the installed service
/description Description for the service
/endpointConfigurationType Specify the type implementing IConfigureThisEndpoint that should be used
/instance Specify the unique name of the service instance you wish to install
ex: "NServiceBus.Host.exe /install /instance:Instance5"
/startManually Specifies that the service should start manually
/username Username for the account the service should run under
/password Password for the service account

If no service name is specified NServiceBus will use the full name of the
endpoint configuration type (that which implements NServiceBus.IConfigureThisEndpoint)
along with the version number of the assembly it is contained within, for example:

MyPublisher.Endpoint_v1.0.0.0

The default for the display name is the same value as the service name, and the description
defaults to a generic NServiceBus host description.

You can also specify the endpoint configuration type in the file NServiceBus.Host.exe.config.
This file is optional.

If you don't specify the endpoint configuration type either in the command-line or in the
NServiceBus.Host.exe.config file, all the DLLs in the runtime directory will be scanned
for a type that implements NServiceBus.IConfigureThisEndpoint.

If you set the service name and/or instance name during installation you will need to specify
them when uninstalling them as well, ex:

NServiceBus.Host.exe /uninstall /serviceName:"MyPublisher" /instance:Instance89

EXAMPLES:
NServiceBus.Host.exe /install /serviceName:"MyPublisher" /displayName:"My Publisher Service"
/description:"Service for publishing event messages"
/endpointConfigurationType:"YourEndpointConfigType.YourNameSpace, YourAssembly"
/username:"corp\serviceuser"
/password:"p@ssw0rd!" NServiceBus.Production
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using Microsoft.Practices.ServiceLocation;

namespace NServiceBus.Hosting.Azure.HostProcess
{
/// <summary>
/// Plugs into the generic service locator to return an instance of <see cref="GenericHost"/>.
/// </summary>
public class HostServiceLocator : ServiceLocatorImplBase
{
/// <summary>
/// Command line arguments.
/// </summary>
public static string[] Args;

/// <summary>
/// Returns an instance of <see cref="GenericHost"/>
/// </summary>
/// <param name="serviceType"></param>
/// <param name="key"></param>
/// <returns></returns>
protected override object DoGetInstance(Type serviceType, string key)
{
var endpoint = Type.GetType(key,true);
return new WindowsHost(endpoint, Args);
}

/// <summary>
/// Not implemented.
/// </summary>
/// <param name="serviceType"></param>
/// <returns></returns>
protected override IEnumerable<object> DoGetAllInstances(Type serviceType)
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{11B81F23-64C6-4341-94AC-38B3C4C6B1E7}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NServiceBus.Hosting.Azure.HostProcess</RootNamespace>
<AssemblyName>NServiceBus.Hosting.Azure.HostProcess</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\..\..\lib\log4net.dll</HintPath>
</Reference>
<Reference Include="Magnum">
<HintPath>..\..\..\lib\Topshelf\Magnum.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation">
<HintPath>..\..\..\lib\ServiceLocation\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="NServiceBus">
<HintPath>..\..\..\build\output\NServiceBus.dll</HintPath>
</Reference>
<Reference Include="NServiceBus.Azure">
<HintPath>..\..\..\build\output\NServiceBus.Azure.dll</HintPath>
</Reference>
<Reference Include="NServiceBus.Core">
<HintPath>..\..\..\build\output\NServiceBus.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Topshelf">
<HintPath>..\..\..\lib\Topshelf\Topshelf.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\CommonAssemblyInfo.cs">
<Link>CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Arguments\HostArguments.cs" />
<Compile Include="HostServiceLocator.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WindowsHost.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NServiceBus.Hosting.Azure\NServiceBus.Hosting.Azure.csproj">
<Project>{6591ED91-F9A1-4CC3-813E-A33E07439D49}</Project>
<Name>NServiceBus.Hosting.Azure</Name>
</ProjectReference>
<ProjectReference Include="..\NServiceBus.Hosting\NServiceBus.Hosting.csproj">
<Project>{B5F333D1-D6B1-49FB-82F6-74641E5D11E3}</Project>
<Name>NServiceBus.Hosting</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Content\Help.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading

0 comments on commit 1da570a

Please sign in to comment.