Re: MassTransit ServiceBusFactory.New() hangs running in TopShelf as Windows Service, not as Console

2,453 views
Skip to first unread message

Jesse Beard

unread,
Mar 22, 2013, 1:22:52 PM3/22/13
to masstrans...@googlegroups.com
In further attempting to track down what is going on, I added some FirstChanceException logging.  When the service starts and MassTransit's ServiceBusFactory.New() returns, I receive the following which I am trying to figure out:

2013-03-22 12:02:29,304 INFO  Unknown - MassModule.Load(): ServiceBusFactory.New() starting...
2013-03-22 12:02:29,336 INFO  Unknown - MassModule.ConfigureServiceBus(): Starting configuration. Running at: C:\dev\CoreMonitoring\Development\CaptiveAire.CoreMonitoring\CaptiveAire.Core.Events.SocketServer.Console\bin\Debug\.
2013-03-22 12:02:29,348 INFO  Unknown - MassModule.ConfigureServiceBus(): [cas-service-bus] using [rabbitmq://caslinkudev1.captiveaire.com/caslink.heartbeats] with [xml] serialization. PurgeOnStartup: True
2013-03-22 12:02:29,355 INFO  Unknown - MassModule.ConfigureServiceBus(): Configuration complete.
2013-03-22 12:02:31,328 ERROR Unknown - System.ArgumentException: None of the discovered or specified addresses match the socket address family.
Parameter name: context
   at System.Net.Sockets.Socket.DoMultipleAddressConnectCallback(Object result, MultipleAddressConnectAsyncResult context)
2013-03-22 12:02:31,328 ERROR Unknown - System.ArgumentException: None of the discovered or specified addresses match the socket address family.
Parameter name: context
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
2013-03-22 12:02:31,329 ERROR Unknown - RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed ---> System.ArgumentException: None of the discovered or specified addresses match the socket address family.
Parameter name: context
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.TcpClient.EndConnect(IAsyncResult asyncResult)
   at RabbitMQ.Client.Impl.SocketFrameHandler_0_9.Connect(TcpClient socket, AmqpTcpEndpoint endpoint, Int32 timeout)
   --- End of inner exception stack trace ---
   at RabbitMQ.Client.Impl.SocketFrameHandler_0_9.Connect(TcpClient socket, AmqpTcpEndpoint endpoint, Int32 timeout)
2013-03-22 12:02:31,329 ERROR Unknown - System.ArgumentException: None of the discovered or specified addresses match the socket address family.
Parameter name: context
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.TcpClient.EndConnect(IAsyncResult asyncResult)
   at RabbitMQ.Client.Impl.SocketFrameHandler_0_9.Connect(TcpClient socket, AmqpTcpEndpoint endpoint, Int32 timeout)
2013-03-22 12:02:31,452 INFO  Unknown - MassModule.Load(): ServiceBusFactory.New() done.
2013-03-22 12:02:31,798 DEBUG MassTransitGlobalEventHandler - MassTransit Global Event [CaptiveAire.Base.DomainEvents.ApplicationStartEvent] @ [rabbitmq://caslinkudev1.captiveaire.com/caslink.heartbeats].
2013-03-22 12:02:31,800 ERROR Unknown - System.ArgumentException: Source property was not set before writing to the event log.

This logging only occurs when the service starts.  If the service hangs in ServiceBusFactory.New(), I do not get any of this logging at all.  I'll keep posting updates and maybe some has seen something similar.

I'm catching first chance exceptions using:

                AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) =>
                    {
                        logger.Error(eventArgs.Exception.ToString());
                        if (eventArgs.Exception.InnerException != null)
                        {
                            logger.Error(eventArgs.Exception.InnerException.ToString());
                        }
                    };

Thanks!


On Friday, March 22, 2013 8:32:22 AM UTC-4, Jesse Beard wrote:
Hi everyone.  First, we are loving what MassTransit is providing for us on top of RabbitMQ.  However, I am having an issue getting ServiceBusFactory.New()to complete when being hosted as a Windows Service.  A bit of detail.  We are using Autofac.  MassTransit is loaded in as an Autofac Module as soon as Main() is executed and then everything is run within a single Autofac LifetimeScope.  We are creating a single instance of IServiceBus with simple configurations from code.  Here is our loading and the logging is purely to help track down the issue of where things are hanging.  Development is Win7, production is 2008R2.

            builder.Register(
                c =>
                    {
                        var logger = c.Resolve<ILog>();

                        logger.Info("MassModule: Load() ServiceBusFactory.New() starting.");
                        var s = ServiceBusFactory.New(sb => this.ConfigureServiceBus(c, sb)); this call does not return every other time; it hangs and times out Windows SCM.
                        logger.Info("MassModule: Load() ServiceBusFactory.New() done.");

                        return s;

                    }).As<IServiceBus>().SingleInstance();

The call to this.ConfigureServiceBus() runs:

private void ConfigureServiceBus([NotNull] IComponentContext context, [NotNull] ServiceBusConfigurator configurator)
{
    CodeContracts.VerifyNotNull(context, "context");
    CodeContracts.VerifyNotNull(configurator, "configurator");

    var logger = context.Resolve<ILog>();
    logger.Info(i => i("Service Bus: Starting service bus configuration at: {0}.", AppDomain.CurrentDomain.BaseDirectory));

    var massModuleSettings = context.Resolve<IAppSettings>().ToTyped<MassModuleSettings>();
    
    configurator.UseRabbitMq();
    configurator.SetPurgeOnStartup(massModuleSettings.PurgeOnStartup);

    // set application queue name.
    configurator.ReceiveFrom(massModuleSettings.ReceiveFrom);

    switch (massModuleSettings.MessageSerializer)
    {
        case "binary":
            configurator.UseBinarySerializer();
            break;
        case "bson":
            configurator.UseBsonSerializer();
            break;
        case "json":
            configurator.UseJsonSerializer();
            break;
        case "xml":
        default:
            configurator.UseXmlSerializer();
            break;
    }

    logger.Info(
        string.Format(
            "Service Bus: [{0}] receiving from [{1}] using [{2}] serialization. PurgeOnStartup: {3}",
            massModuleSettings.ServiceBusNetwork,
            massModuleSettings.ReceiveFrom,
            massModuleSettings.MessageSerializer,
            massModuleSettings.PurgeOnStartup));

    foreach (var setupServiceBus in context.Resolve<IEnumerable<ISetupServiceBus>>())
    {
        setupServiceBus.Setup(configurator);
    }

    logger.Info("Service Bus: Starting service bus configuration complete.");
}

When our host process starts, the Console application that is using TopShelf, the very first thing that happens is our Autofac container is built and the TopShelf service is configured. I have a single custom command line argument that dictates how the service starts.  This must be extracted from the command line before TopShelf takes over and passed to the Container for proper setup and configuration.  The parsing of the command line ahead of TopShelf is a little janky, I know.

        static void Main(string[] args)
        {
//            AppDomain.CurrentDomain.FirstChanceException +=
//                (sender, eventArgs) => Console.WriteLine(eventArgs.Exception.ToString());

            // manually extract the supplied 'server' argument so it can be passed to GlobalContainer.
            var commandLineServerType = int.Parse(args.First().Split(new[] { '=' })[1]);
            
            using (var container = new GlobalContainer(commandLineServerType).Build()) Autofac Module for MassTransit is registered here creating IServiceBus
            {
                var settings = container.Resolve<SocketServerSettings>();
                
                HostFactory.Run(
                    cfg =>
                    {
                        // register the custom command line option that dictates runtime server type.
                        // this registration also prevents TopShelf from rejecting the argument and stopping.
                        cfg.AddCommandLineDefinition("type", x => { /* do nothing */ });
                        cfg.ApplyCommandLine();

                        // configure the service class.
                        cfg.Service<ServiceControl>(
                            svc =>
                            {
                                svc.ConstructUsing(container.Resolve<ServiceControl>);
                                svc.WhenStarted((service, hostControl) => service.Start(hostControl));
                                svc.WhenStopped((service, hostControl) => service.Stop(hostControl));
                            });

                        // used for Windows Service installation.
                        cfg.SetDescription(settings.Description);
                        cfg.SetDisplayName(string.Format("Blah-{0}", settings.ServerName));
                        cfg.SetServiceName(string.Format("Blah-{0}", settings.ServerName));

                        // wait until the server is pretty much done starting before starting services.
                        cfg.DependsOn("LanmanWorkstation");

                        // initially configure the Windows Services to install using Local System account.
                        // this should and will be changed post-deploy using a script.
                        cfg.RunAsLocalSystem();
                    });  
            }
        } 

Within the Start() method of the ServiceControl class being used to host our TopShelf service:

        public bool Start(HostControl hostControl)
        {
            hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(15));

            this.SocketServer = this.LifetimeScope.Resolve<ISocketServer>();
            this.SocketServer.BindToIP = this.SocketServerSettings.IPAddress;
            this.SocketServer.BindToPort = this.SocketServerSettings.Port;
            this.SocketServer.Type = this.SocketServerSettings.Type;
            this.SocketServer.ServerName = this.SocketServerSettings.ServerName;

            new Task<bool>(this.SocketServer.Run).Start();

            return true;
        }

There are no issues whatsoever when running as Console.  Everything loads and starts within a second or so.  When running as Windows Service, MassTransit has issues for some reason.  This is really only occurring every other start of the service.  Either it works or fails the first time and then it's every other start that works.  I'm running the Windows Service as an administrator with full access to all local and network resources.  Our RabbitMQ instances are hosted on Ubuntu server.

I am using Octopus deploy for production and staging deployments.  The only solution at the moment for my Powershell install scripts is to check for start failure and try again, which I really prefer not to have to do because that may be hiding a larger issue that needs dealing with.  I have also verified my current directory is correct when the Windows Service loads.  TopShelf is setting that properly.

Any assistance would be greatly appreciated and I can provide more code and details if needed.

Thanks!

Jesse Beard

unread,
Mar 22, 2013, 1:27:23 PM3/22/13
to masstrans...@googlegroups.com
package versions installed via nuget:

  <package id="Autofac" version="3.0.1" targetFramework="net45" />
  <package id="Autofac.Extras.Multitenant" version="3.0.0-beta2" targetFramework="net45" />
  <package id="Castle.Core" version="3.0.0.4001" targetFramework="net45" />
  <package id="Common.Logging" version="2.1.2" targetFramework="net45" />
  <package id="Common.Logging.Log4Net" version="2.0.1" targetFramework="net45" />
  <package id="log4net" version="1.2.10" targetFramework="net45" />
  <package id="Magnum" version="2.1.0" targetFramework="net45" />
  <package id="MassTransit" version="2.7.1" targetFramework="net45" />
  <package id="MassTransit.RabbitMQ" version="2.7.1" targetFramework="net45" />
  <package id="OctoPack" version="1.0.111" targetFramework="net45" />
  <package id="RabbitMQ.Client" version="3.0.4" targetFramework="net45" />
  <package id="Rx-Core" version="2.1.30214.0" targetFramework="net45" />
  <package id="Rx-Interfaces" version="2.1.30214.0" targetFramework="net45" />
  <package id="Rx-Linq" version="2.1.30214.0" targetFramework="net45" />
  <package id="Rx-PlatformServices" version="2.1.30214.0" targetFramework="net45" />
  <package id="TopShelf" version="3.1.0" targetFramework="net45" />

Jesse Beard

unread,
Mar 22, 2013, 2:22:17 PM3/22/13
to masstrans...@googlegroups.com
I have narrowed this down to MassTransit trying to install/update its performance counters.  Now to fix the permissions issue or disable the counters.  Right now, I don't care about performance counters.

Chris Patterson

unread,
Mar 22, 2013, 4:19:01 PM3/22/13
to masstrans...@googlegroups.com
The creation of performance counters (or inability thereof) does not stop the service bus from starting. The error appears to be how it is trying to connect to the RabbitMQ server and the hostname not being resolved.

Is there a chance/reason that the address: caslinkudev1.captiveaire.com would not be resolved?


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/Vctn242rJs0J.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jesse Beard

unread,
Mar 22, 2013, 4:31:24 PM3/22/13
to masstrans...@googlegroups.com
Chris, thank you for the feedback.  I have narrowed down the "hang point".  Here it is:

int missing = counters
.Where(counter => !PerformanceCounterCategory.CounterExists(counter.Name, CategoryName))
.Count();

This is called in ServiceBusPerformanceCounters.InitializeCategory().

Here is the steps that leads me to believe this:

Just before ServiceBusFactory.New() in my code, I have:  Debugger.Launch();

            builder.Register(
                c =>
                    {
                        var logger = c.Resolve<ILog>();
                        logger.Info("MassModule.Load(): ServiceBusFactory.New() starting...");

                        IServiceBus s;

                        try
                        {
                            Debugger.Launch();
                            s = ServiceBusFactory.New(sb => this.ConfigureServiceBus(c, sb));
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex);
                            throw;
                        }
                        
                        logger.Info("MassModule.Load(): ServiceBusFactory.New() done.");

                        return s;

                    }).As<IServiceBus>().SingleInstance();

Next, I set breakpoints until I found the sore spot.  Every other start of the service, The CounterExists() call hangs and never returns.  The reverse, every other call it succeeds.  I am very stumped here.  I have even followed MS advice here:


...for adding your user to the Performance Monitor Users group, but again, I am running as admin (still added to the group).  I have also set Full Control permissions on the key in the registry mentioned here:


No luck on any of this.  However, the counters are created and visible in the Performance monitor UI.  :(

Concerning the machine caslinkudev1.captiveaire.com, there is no name resolution issues.  nslookup and ping never fail to resolve.  That Ubuntu VM is located in a server room next to me as well.  No issues there.

Regardless of that error, rabbitmq works great and MT pumps all the messages through without fail.

Just in case this helps any:

host.machine_name: JESSEBEARD-IMAC
mt.concurrent_receive_threads: 1
mt.default_serializer: XmlMessageSerializer
mt.max_consumer_threads: 32
mt.network: jessebeard-imac
mt.receive_timeout: 00:00:03
mt.service_count: 3
mt.transport: [loopback] LoopbackTransportFactory
mt.transport: [rabbitmq] RabbitMqTransportFactory
mt.version: 2.7.0.0
net.version: 4.0.30319.17929
os.bits: x64
os.version: Microsoft Windows NT 6.1.7601 Service Pack 1
process.bits: x64
process.id: 22912
zz.mt.inbound_pipeline: Pipeline
Routed (MassTransit.IConsumeContext, MassTransit)
Translated to MassTransit.Diagnostics.Tracing.GetMessageTraceList, MassTransit
Routed (MassTransit.Diagnostics.Tracing.GetMessageTraceList, MassTransit)
Consumed by Instance (MassTransit.Diagnostics.Tracing.GetMessageTraceList, MassTransit)
Translated to CaptiveAire.Core.Events.SocketServers.ProcessedSensorsReadyEvent, CaptiveAire.Core.Events
Routed (CaptiveAire.Core.Events.SocketServers.ProcessedSensorsReadyEvent, CaptiveAire.Core.Events)
Consumed by Instance (CaptiveAire.Core.Events.SocketServers.ProcessedSensorsReadyEvent, CaptiveAire.Core.Events)
Translated to CaptiveAire.Core.Events.SocketServers.SubscribeToNewSensorData, CaptiveAire.Core.Events
Routed (CaptiveAire.Core.Events.SocketServers.SubscribeToNewSensorData, CaptiveAire.Core.Events)
Consumed by Instance (CaptiveAire.Core.Events.SocketServers.SubscribeToNewSensorData, CaptiveAire.Core.Events)

zz.mt.outbound_pipeline: Pipeline
Interceptor
Routed (MassTransit.ISendContext, MassTransit)


Thanks so much for any pointers, etc. on this.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
Mar 22, 2013, 4:37:31 PM3/22/13
to masstrans...@googlegroups.com
I can't think why it would fail to query the existence of the performance counters, more importantly why it would hang trying to do so. I can see if it threw an exception, as that is handled and ignored.


To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

Jesse Beard

unread,
Mar 22, 2013, 4:58:28 PM3/22/13
to masstrans...@googlegroups.com
Alright, so lots of talk on the web about this specific call hanging that I mentioned.  SignalR guys have some Github threads mentioning it as well.  So for sure it is not a MT issue, but a nasty Windows issue.

Chris, any chance you can make your Performance Counters optional in MT via a UsePerformanceCounters() call or something appropriate?  I feel I am going to have to resort to compiling MT source local and disabling this call....which I really don't want to have to do.

I'll keep researching.....
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/Vctn242rJs0J.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
Mar 22, 2013, 5:28:01 PM3/22/13
to masstrans...@googlegroups.com
I think we can do something there, can you add an issue on GitHub to track it?

http://github.com/MassTransit/MassTransit - add an issue there so I can work it.


To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

Jesse Beard

unread,
Mar 22, 2013, 5:29:05 PM3/22/13
to masstrans...@googlegroups.com
Will do. Thanks Chris!
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/oLjb9xdABWgJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Jesse Beard

unread,
Mar 22, 2013, 5:42:22 PM3/22/13
to masstrans...@googlegroups.com

Anders Ljusberg

unread,
Apr 1, 2013, 4:12:58 PM4/1/13
to masstrans...@googlegroups.com
Sorry for jumping in a bit late but we had this very problem as well. Interesting to see that it's related to performance counters.

Anyway, we found a work-around for it. If we delay creating the bus until the Start method, it all starts up nice every time.

/Anders

Chris Patterson

unread,
Apr 1, 2013, 5:30:46 PM4/1/13
to masstrans...@googlegroups.com
Oh, wow, I can't believe I missed this!

All of the container setup, etc. should be done ENTIRELY in the ConstructUsing() method of the service, and not outside the Topshelf configuration. Otherwise, you can't be certain the service is actually ready to start doing things yet! You also won't get proper exception handling in the event of a broken container configuration or anything else.

Yes, I realize some people may be "getting lucky" doing things before the service is constructed/started, but there are many command line options that do not actually create and/or start the service, so please defer that initialization until code that's actually inside the service configuration.


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

Jesse Beard

unread,
Apr 1, 2013, 5:35:19 PM4/1/13
to masstrans...@googlegroups.com
Now that is the only solution I have not tried.  I'll see if I can rework my Main() code to move everything into the ConstructUsing().  For now, we forked and added configuration to not load performance counters and are compiling it local via our TeamCity and making a nuget package for it.  If I can get my stuff to start properly using this new info, I won't need the fork...maybe (prefer not to have it).

Thanks!!

On Monday, April 1, 2013 5:30:46 PM UTC-4, Chris Patterson wrote:
Oh, wow, I can't believe I missed this!

All of the container setup, etc. should be done ENTIRELY in the ConstructUsing() method of the service, and not outside the Topshelf configuration. Otherwise, you can't be certain the service is actually ready to start doing things yet! You also won't get proper exception handling in the event of a broken container configuration or anything else.

Yes, I realize some people may be "getting lucky" doing things before the service is constructed/started, but there are many command line options that do not actually create and/or start the service, so please defer that initialization until code that's actually inside the service configuration.
On Mon, Apr 1, 2013 at 1:12 PM, Anders Ljusberg <and...@gmail.com> wrote:
Sorry for jumping in a bit late but we had this very problem as well. Interesting to see that it's related to performance counters.

Anyway, we found a work-around for it. If we delay creating the bus until the Start method, it all starts up nice every time.

/Anders


On Friday, March 22, 2013 10:42:22 PM UTC+1, Jesse Beard wrote:
Github issue:


Thanks!
Jesse

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

Mehdi El Gueddari

unread,
Nov 27, 2013, 5:24:28 PM11/27/13
to masstrans...@googlegroups.com

On Monday, April 1, 2013 10:30:46 PM UTC+1, Chris Patterson wrote:
Oh, wow, I can't believe I missed this!

All of the container setup, etc. should be done ENTIRELY in the ConstructUsing() method of the service, and not outside the Topshelf configuration. Otherwise, you can't be certain the service is actually ready to start doing things yet! You also won't get proper exception handling in the event of a broken container configuration or anything else.

We ran into the exact same problem as the OP. The only difference is that we're using Castle Windsor instead of Autofac as our IoC container. Just like the OP, we traced this issue down to a call to ServiceBusFactory.New(), which hung half of the time at startup when our app ran as a Windows Service (no problem when running it as a console app). 

We were already doing all the initialization in the ConstructUsing() method of the service (creating and configuring a WindsorContainer and using it to resolve an instance of our service class, which would result in a call to ServiceBusFactory.New() being made behind the scenes). So that's not the culprit. 

Just like Anders, we fixed the issue by delaying the initialisation of our service. Or more accurately: instead of instantiating our service class (which results in MassTransit getting initialised) in the ConstructUsing() method of TopShelf, we kick off a new thread and do the service instantiation in that background thread. 

It's worth noting that the problem isn't that our service instantiation or initialisation takes too long. Now that it's being done in a background thread, it's always very fast (a couple of seconds at most) and it never hangs. It seems that calling ServiceBusFactory.New() in the startup thread of a Windows Service somehow causes a deadlock somewhere half of the time.

In practice, we achieved this by creating a stub service class. Instead of getting TopShelf to instantiate our real service class, we get it to instantiate and start-up our stub class . That stub service then creates a background thread and instantiates our real service class there. That's what the stub service class looks like:

    public class ServiceStub : ServiceControl

    {

        private Thread _thread;

        private IRealService _realServiceInstance;


        public bool Start(HostControl hostControl)

        {

            _thread = new Thread(InternalStart);

            _thread.Start();

            return true;

        }


        public bool Stop(HostControl hostControl)

        {

            _thread.Join();

            _realServiceInstance.Stop();

            // Other cleanup

            return true;

        }


        private void InternalStart()

        {

            // Create IoC container and configure it.

            // Use IoC container to resolve instance of IRealService and call its Start() method.

        }

    }


The TopShelf configuration then becomes trivial:

            HostFactory.Run(x =>

            {

                x.Service<ServiceStub>();


                // Any other TopShelf config here

            });


Cheers,

Mehdi

Eugene Krapivin

unread,
Dec 9, 2014, 3:46:05 AM12/9/14
to masstrans...@googlegroups.com
I've encountered this problem and found a rather stupid fix to it.
The topshelf start/stop methods are just empty methods that do not contain anything that might compromise the initiation of the service as a service.
Right after the initiation of the service I run the masstransit initiations.


On Friday, March 22, 2013 2:32:22 PM UTC+2, Jesse Beard wrote:
Hi everyone.  First, we are loving what MassTransit is providing for us on top of RabbitMQ.  However, I am having an issue getting ServiceBusFactory.New()to complete when being hosted as a Windows Service.  A bit of detail.  We are using Autofac.  MassTransit is loaded in as an Autofac Module as soon as Main() is executed and then everything is run within a single Autofac LifetimeScope.  We are creating a single instance of IServiceBus with simple configurations from code.  Here is our loading and the logging is purely to help track down the issue of where things are hanging.  Development is Win7, production is 2008R2.

            builder.Register(
                c =>
                    {
                        var logger = c.Resolve<ILog>();

                        logger.Info("MassModule: Load() ServiceBusFactory.New() starting.");
                        var s = ServiceBusFactory.New(sb => this.ConfigureServiceBus(c, sb)); this call does not return every other time; it hangs and times out Windows SCM.
                        logger.Info("MassModule: Load() ServiceBusFactory.New() done.");

                        return s;

                    }).As<IServiceBus>().SingleInstance();
Reply all
Reply to author
Forward
0 new messages