Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "BobIngham"

Hi @ajayak, If you're happy working with Hangfire then stick with Hangfire only. Invoke Hangfire in your WebCoreModule as above. Place your job in the HangfireService:

public class HangfireService
{
    public static void InitializeJobs()
    {
        RecurringJob.AddOrUpdate<ShipmentAddressLocationCoordinatesWorker>(job => job.Execute(0), "50 1 * * 0");
        return;
    }
}

Then your worker looks something like below. You are trying to run an abp background worker by firing it from Hangfire.

namespace Nuagecare.Web.Hangfire.Workers
{
    public class UpdateFromDataProvider : BackgroundJob<int>, ITransientDependency
    {
        public IAbpSession _abpSession;
        private readonly IRepository<Tenant> _tenantRepository;
        private readonly DataProviderAPIProvider _dataProviderAPIProvider;


        public UpdateFromDataProvider(
            IAbpSession abpSession,
            IRepository<Tenant> tenantRepository,
            DataProviderAPIProvider dataProviderAPIProvider)
        {
            _abpSession = abpSession;
            _tenantRepository = tenantRepository;
            _dataProviderAPIProvider = dataProviderAPIProvider;
        }

        [DisableConcurrentExecution(timeoutInSeconds: 10 * 60)]
        [AutomaticRetry(Attempts = 0)]
        public override void Execute(int number)
        {
            var env = AppDomain.CurrentDomain.GetData("HostingEnvironment") as IHostingEnvironment;
            ... code removed for brevity

Hopefully that shuold be a little clearer. Here's how it looks in VS. Probably the guys at Zero will tell me I have everything wrong!!!! This has been up and working in an Azure production site for over a year and never fails.

@ajayak When you use Hangfire it's initialised in your Startup and instantiated in your WebCoreModule, which you probably already know:

if (WebConsts.HangfireDashboardEnabled)
{
    //Hangfire(Enable to use Hangfire instead of default job manager)
    services.AddHangfire(config =>
    {
        config.UseSqlServerStorage(_appConfiguration.GetConnectionString("Default"));
        HangfireService.InitializeJobs();
    });
}

Your HangfireService class triggers jobs using standard CRON scheduling:

public class HangfireService
{
    public static void InitializeJobs()
    {
        RecurringJob.AddOrUpdate<UpdateFromDataProvider>(job => job.Execute(0), "30 * * * *");
        return;
    }
}

Zero's background jobs work a little differently. They are instantiated into your WebHostModule:

if (IocManager.Resolve<IMultiTenancyConfig>().IsEnabled)
{
    var workManager = IocManager.Resolve<IBackgroundWorkerManager>();
    workManager.Add(IocManager.Resolve<SubscriptionExpirationCheckWorker>());
    workManager.Add(IocManager.Resolve<SubscriptionExpireEmailNotifierWorker>());
}

And the timing is declared at the top of the Worker class:

namespace Nuagecare.MultiTenancy
{
    public class SubscriptionExpirationCheckWorker : PeriodicBackgroundWorkerBase, ISingletonDependency
    {
        private const int CheckPeriodAsMilliseconds = 1 * 60 * 60 * 1000; //1 hour

Hope that helps. Zero's background workers and Hangfire workers can work, it's not one or the other, it can be both.

Hi @demirmusa, now I understand - I have always used Hangfire for my background jobs so took me a little while to figure out how the Zero implementation works. Now I can see it, thanks to your help.

Thanks, @maliming. I will carry out the necessary changes in the AppSettingsProvider.

You can for me, I'm sure @mitch has sorted his problem so won't mind this being closed.

Thanks @maliming. I don't want to add another nuget package for the sake of declaring a [HttpGet] atttribute. This is down to naming conventions, by renaming the Restore method to GetRestore I was able to circumvent the problem. Hardly ideal, but hey-ho! Thanks for your help in the meantime, you pointed me in thye right direction.

Hi @demirmusa, Thanks for getting back so promptly. That's perfect for what I need to investigate, at least I now know where to look. Where does the system trigger SubscriptionExpireEmailNotifierWorker.DoWork(), I can see the variable CheckPeriodAsMilliseconds is set to every day at the top of SubscriptionExpireEmailNotifierWorker. I haven't been able to find documentation on how these background jobs are invoked.

Hi @maliming, thanks for getting back. How do I do what you suggest in my service layer?

Answer

It wouldn't be a problem for me, I seed my tenants with a store procedure, that way the5re's no requirement for a release when seed data changes.

Answer

Nope, I don't use separate tenant databases. Why, is this method a problem for separate databases?

Showing 91 to 100 of 477 entries