Hi,
since it is just a sngile module/ dll I dont want to use the complete folder path here (otherwise it would iterate through all dlls). Is it possible to just add one modul?
The application is alive and azure is configured to dont shut down. The problem exist randomly if I start debugging or deploy a new version. I think for some reasons it randomly failed to register the dependencies
Hi hikalkan,
During the last month I traced the issue a lot. However, I cant find the root of the problem. Here is my scenario:
Do you have any idea how to get rid of it?
Hi,
No, I have no dependency to MyModule. The project is a class library, that is deployed via the web application that comes with the template. MyModule implements AbpModule. The main goal of the module is to execute recurring jobs (some should execute every 2 minutes, some every hour). The jobs are registered in hangfire and access code in .Application project. It is strange because the jobs run fine for 30 minutes. After that it seems like castle "forget" the reference.
I have done some refectoring to make the problem more clear. I seperate the job into an own class:
public class JobDefinition : ITransientDependency
{
private readonly IIocResolver _iocResolver;
public JobDefinition(IIocResolver iocResolver)
{
_iocResolver = iocResolver;
}
[DisplayName("Import qutations from url {0}")]
[AutomaticRetry(Attempts = 0, OnAttemptsExceeded = AttemptsExceededAction.Delete)]
public void QutationImportServiceJobDefinition(string tenant, string url)
{
var qutationImportService = _iocResolver.Resolve<IQutationImportService>();
qutationImportService.Start(tenant, url);
}
}
Here is the definition of the module:
[DependsOn(typeof(AbpHangfireModule))]
public class MyModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
Configuration.BackgroundJobs.UseHangfire(
configuration => { configuration.GlobalConfiguration.UseSqlServerStorage("Default"); });
}
public override void PostInitialize()
{
base.PostInitialize();
var jobDefinition = new JobDefinition(IocManager);
//Every 2 minutes
RecurringJob.AddOrUpdate($"Job for {tenant}",
() => jobDefinition.QutationImportServiceJobDefinition("---", "http://google.com"),
"*/2 * * * *");
}
}
The exception is:
JobDefinition jobDefinition = Activate<JobDefinition>(); jobDefinition.QutationImportServiceJobDefinition();
Failed An exception occurred during processing of a background job.
Castle.MicroKernel.ComponentNotFoundException
No component for supporting the service JobDefinition was found Castle.MicroKernel.ComponentNotFoundException: No component for supporting the service JobDefinition was found at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy) at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments) at Castle.Windsor.WindsorContainer.Resolve(Type service) at Abp.Dependency.IocManager.Resolve(Type type) at Abp.Hangfire.HangfireIocJobActivator.ActivateJob(Type jobType) at Abp.Hangfire.HangfireIocJobActivator.HangfireIocJobActivatorScope.Resolve(Type type) at Hangfire.Server.CoreBackgroundJobPerformer.Perform(PerformContext context) at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass8_0.<PerformJobWithFilters>b__0() at Hangfire.Server.BackgroundJobPerformer.InvokePerformFilter(IServerFilter filter, PerformingContext preContext, Func
1 continuation) at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass8_1.<PerformJobWithFilters>b__2() at Hangfire.Server.BackgroundJobPerformer.PerformJobWithFilters(PerformContext context, IEnumerable
1 filters) at Hangfire.Server.BackgroundJobPerformer.Perform(PerformContext context) at Hangfire.Server.Worker.PerformJob(BackgroundProcessContext context, IStorageConnection connection, String jobId)
The application runs on the latest version of ABP. The secneario is the same deployed to my local IIS/ to azure. The application is set to "run always".
Do you have any idea why it "forgets" the reference? If you have any other idea how to register jobs in a seperate module that are executed with hangfire I can also follow this guidance.
Thank, that worked!
Thanks. That solved my problem
Thanks, this fixed my problem
Hey Hikalkan,
since Patrick also has this problem: Is this maybe a general problem with automatic generated mapping entities? Do you have any idea how to track this one?
Thank you!
Hi, Yes, in controller the countries are added. This was just a test. I rewrite the test code, in following scenario a country with id 2 is loaded. However, the mapping is still not saved:
public async Task SaveAsync(IProvider provider, bool saveChanges = true)
{
var entity = provider as Provider;
if (entity == null)
throw new ArgumentNullException(nameof(provider));
//Clear existing entities
entity.Countries= new List<Country>();
var country = _countryRepository.Get(2);
entity.Countries.Add(country);
_providerRepository.InsertOrUpdate(entity);
if (saveChanges)
{
await CurrentUnitOfWork.SaveChangesAsync();
}
}
I have a SaveAsync method that accepts the provider entity and adds countries here
public async Task SaveAsync(Provider provider)
{
var entity = provider;
var countriesToAdd = provider.Countries.ToList();
//Clear existing entities
entity.Countries.Clear();
foreach (var countryToAdd in countriesToAdd)
{
var country = _countryRepository.Get(countryToAdd.Id);
entity.Countries.Add(country);
}
_providerRepository.InsertOrUpdate(entity);
await CurrentUnitOfWork.SaveChangesAsync();
}