How to get instance or setup in StructureMap IBus in the worker role where I already use AsA_Worker, UsingTransport<AzureServiceBus>

StackOverflow https://stackoverflow.com/questions/19857969

سؤال

I have a problem. I setup azure worker role which use NServiceBus with Azure Service Bus:

public class Host : NServiceBus.Hosting.Azure.RoleEntryPoint
    {    

        public override bool OnStart()
        {
            RegisterByObjectFactory.Register();

            ServicePointManager.DefaultConnectionLimit = 12;

            return base.OnStart();
        }
...

In my worker role I use services which have parameters IBus.

Spent 3 days to figure out how to do it but still without success.

If I try to inject the NserviceBus in the RegisterByObjectFactory then on row "return base.OnStart();" I receive the error that the ConnectionString property was locked :(

Please help.

هل كانت مفيدة؟

المحلول

Onstart is probably a bit to early in the lifecycle of nservicebus to get hold of the bus.

Implement a class with the interface IWantToRunWhenTheBusStartsAndStops and you should have access to the fully initialized IBus instance there...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top