Hangfire: 1.6.5 BackgroundJob.Enqueue no longer functional

Created on 28 Sep 2016  Â·  18Comments  Â·  Source: HangfireIO/Hangfire

You guys release some of the worst updates I have ever seen!

question

Most helpful comment

@odinserj Patience of a saint...

All 18 comments

Could you elaborate more what's happened (i.e. exception, message, screenshots, just more details) and what storage are you using?

Nothing happens. Literally nothing.

even BackgroundJob.Enqueue(() => System.Console.WriteLine("sgfueoh")); produces no output.

By literally nothing happens, I mean no exceptions, no message, no details. Nothing.

The server is configured by: GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireDB");

Could you not have just, you know, tested it ONCE before releasing it?

Just tried to reproduce the issue, everything is working fine.

namespace ConsoleApplication50
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.UseHangfireServer();
            app.UseHangfireDashboard("");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            GlobalConfiguration.Configuration
                .UseSqlServerStorage(@"Server=.\sqlexpress;database=issue679;integrated security=true");

            BackgroundJob.Enqueue(() => Console.WriteLine("Hello, World!"));

            using (WebApp.Start<Startup>("http://localhost:12345"))
            {
                Console.ReadLine();
            }
        }
    }
}

image

image

Would you like to share a repository on GitHub that reproduces the issue? Have you tried to enable the logging, at least to the Console.Out:

GlobalConfiguration.Configuration
    .UseColouredConsoleLogProvider()
    .UseSqlServerStorage(@"Server=.\sqlexpress;database=issue679;integrated security=true");

You might want to create a new project, download 1.6.5 with Nuget and try that again, because it will not work.

I just downgrade to 1.6.1, rebuild and run and everything works like it's supposed to.

Even better, create a new project, download 1.6.1 with Nuget, build and run the example, then update to 1.6.5, run, and you will see the issue then.

You might want to create a new project, download 1.6.5 with Nuget and try that again, because it will not work.

I've already did this, as you can see in my previous comment, but wasn't able to reproduce the issue. There's something different in your environment, and I need to know what is it to help you to resolve the issue.

Even better, create a new project, download 1.6.1 with Nuget, build and run the example, then update to 1.6.5, run, and you will see the issue then.

I've also just updated Hangfire.Highlighter sample from 1.6.1 to 1.6.5 to reproduce the issue, it's working fine too – http://highlighter.hangfire.io.

I'm here and I'm ready to help, but I can't do that without your involvement. Have you tried to set up the logging, it may help to reveal exceptions happening in the background:

GlobalConfiguration.Configuration
    .UseColouredConsoleLogProvider()
    .UseSqlServerStorage(@"Server=.\sqlexpress;database=issue679;integrated security=true");

In Startup.cs, if I do

public void Configuration(IAppBuilder app) {
            ConfigureAuth(app);
            BackgroundJob.Enqueue(() => NetComms.NetworkThings.StartListening());
      }

and in Application_Start() in Global.asax.cs I do:

            GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireDB");
            _backgroundJobServer = new BackgroundJobServer();

It seems to work then with 1.6.5

Could you tell me what was your previous setup?

I had the server configuration right above the BackgroundJob.Enqueue, inside Configuration()

That should work too, and that works in my case. Could you share the source code of your previous setup?

That's really it, I don't put anything else in there besides what ASP.NET auto generated. Then I should ask if one of these setups is preferable or if one of them should not work?

    public class MvcApplication : System.Web.HttpApplication {

        private BackgroundJobServer _backgroundJobServer;

        protected void Application_Start() {
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireDB");
            _backgroundJobServer = new BackgroundJobServer();
        }
    }

and

        public void Configuration(IAppBuilder app) {
            ConfigureAuth(app);
            BackgroundJob.Enqueue(() => NetComms.NetworkThings.StartListening());
        }

That is the only code I have that interacts with Hangfire

Could you share the source code of your previous setup by pasting it here? Otherwise our discussion is pointless, because I've tried every possible sequence of method calls, and all of them working fine.

Previously I was doing

        public void Configuration(IAppBuilder app) {
            ConfigureAuth(app);
            GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireDB");
            BackgroundJob.Enqueue(() => NetComms.NetworkThings.StartListening());
        }

and that was the only code I had anywhere for Hangfire

You need to start at least one instance of background job server in order to process your jobs in any version of Hangfire. Without it nothing will happen like in your case.

public void Configuration(IAppBuilder app) 
{
    ConfigureAuth(app);
    GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireDB");

    // Without this line background processing will not be performed
    // in any version of Hangfire.
    app.UseHangfireServer();

    BackgroundJob.Enqueue(() => NetComms.NetworkThings.StartListening());
}

Yes, sorry, that is exactly how I had it, but I think that is functioning now with 1.6.5. I don't know if the issue was old references or something but maybe cleaning/rebuilding many times has fixed it

Okay, glad to hear all is working fine!

@odinserj Patience of a saint...

Was this page helpful?
0 / 5 - 0 ratings