public override void Initialize()
 {
     Configure.Component <MessageMapper>(DependencyLifecycle.SingleInstance);
     Configure.Component <SystemXmlMessageSerializer>(DependencyLifecycle.SingleInstance)
     .ConfigureProperty(p => p.SkipWrappingElementForSingleMessages, !SettingsHolder.GetOrDefault <bool>("SerializationSettings.WrapSingleMessages"));
     SettingsHolder.ApplyTo <SystemXmlMessageSerializer>();
 }
        public override void Initialize()
        {
            CloudQueueClient queueClient;

            var configSection = NServiceBus.Configure.GetConfigSection <AzureQueueConfig>();

            var connectionString = TryGetConnectionString(configSection);

            if (string.IsNullOrEmpty(connectionString))
            {
                queueClient = CloudStorageAccount.DevelopmentStorageAccount.CreateCloudQueueClient();
            }
            else
            {
                queueClient = CloudStorageAccount.Parse(connectionString).CreateCloudQueueClient();

                Address.OverrideDefaultMachine(connectionString);
            }

            NServiceBus.Configure.Instance.Configurer.RegisterSingleton <CloudQueueClient>(queueClient);

            NServiceBus.Configure.Component <AzureMessageQueueReceiver>(DependencyLifecycle.InstancePerCall)
            .ConfigureProperty(p => p.PurgeOnStartup, ConfigurePurging.PurgeRequested);
            NServiceBus.Configure.Component <AzureMessageQueueSender>(DependencyLifecycle.InstancePerCall);
            NServiceBus.Configure.Component <PollingDequeueStrategy>(DependencyLifecycle.InstancePerCall);
            NServiceBus.Configure.Component <AzureMessageQueueCreator>(DependencyLifecycle.InstancePerCall);


            SettingsHolder.ApplyTo <AzureMessageQueueReceiver>();

            if (configSection != null && !string.IsNullOrEmpty(configSection.QueueName))
            {
                var queueName = configSection.QueueName;

                if (SettingsHolder.GetOrDefault <bool>("AzureMessageQueueReceiver.QueuePerInstance"))
                {
                    queueName = QueueIndividualizer.Individualize(queueName);
                }

                NServiceBus.Configure.Instance.DefineEndpointName(queueName);
            }
            else if (IsRoleEnvironmentAvailable())
            {
                NServiceBus.Configure.Instance.DefineEndpointName(RoleEnvironment.CurrentRoleInstance.Role.Name);
            }
            Address.InitializeLocalAddress(NServiceBus.Configure.EndpointName);
        }
Ejemplo n.º 3
0
        public override void Initialize()
        {
            InfrastructureServices.Enable <IAutoSubscriptionStrategy>();

            if (Configure.HasComponent <DefaultAutoSubscriptionStrategy>())
            {
                var transportDefinition = SettingsHolder.GetOrDefault <TransportDefinition>("NServiceBus.Transport.SelectedTransport");

                //if the transport has centralized pubsub we can auto-subscribe all events regardless if they have explicit routing or not
                if (transportDefinition != null && transportDefinition.HasSupportForCentralizedPubSub)
                {
                    Configure.Instance.Configurer.ConfigureProperty <DefaultAutoSubscriptionStrategy>(s => s.DoNotRequireExplicitRouting, true);
                }

                //apply any user specific settings
                SettingsHolder.ApplyTo <DefaultAutoSubscriptionStrategy>();
            }
        }