Base solution for your next web application
Open Closed

ExecuteAsync not being called in AsyncBackgroundJob #10699


User avatar
1
DanielNikolic created

Product version: 10.3.0 Product type: Angular Product framework type: .net core ABP Framework version: 6.3.0.0

I'm in the process of implementing import functionality, but the AsyncBackgroundJob's ExecuteAsync is not being called, a exception is happening inside Abp.BackgroundJobs.BackgroundJobManager but I can't step into that part of the code base. Here are the steps I take when I compe up against this issue:

  1. I go to users and import an excel file
  2. The thread executes ImportFromExcel(), the file is saved inside the database, everything appears to be going correctly
  3. The constructor of the background job is called, so BackgroundJobManager is instantiating the job
  4. ExecuteAsync is never called. ImportUsersToExcelJob is being instantiated repeatedly by BackgroundJobManager in the background but ExecuteAsync is never called.

If I look in the Logs.txt, I see the following exception when BackgroundJobManager attempts to run the job

SELECT TOP(@__p_1) [a].[Id], [a].[CreationTime], [a].[CreatorUserId], [a].[IsAbandoned], [a].[JobArgs], [a].[JobType], [a].[LastTryTime], [a].[NextTryTime], [a].[Priority], [a].[TryCount] FROM [AbpBackgroundJobs] AS [a] WHERE ([a].[IsAbandoned] <> CAST(1 AS bit)) AND ([a].[NextTryTime] <= @__Now_0) ORDER BY [a].[Priority] DESC, [a].[TryCount], [a].[NextTryTime] WARN 2021-11-23 09:59:47,962 [4 ] Abp.BackgroundJobs.BackgroundJobManager - Object does not match target type. System.Reflection.TargetException: Object does not match target type. at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target) at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Abp.BackgroundJobs.BackgroundJobManager.TryProcessJobAsync(BackgroundJobInfo jobInfo)

An exception is being thrown in BackgroundJobManager. Why is this exception being thrown? Is there a serialization/parsing error happening somewhere? I've tried changing ImportUsersFromExcelJobArgs to a simpler object. I've tried adding [Serializable] to it as well, but it doesn't seem to help.

If you've got any ideas, I'd appreciate it.


4 Answer(s)
  • User Avatar
    0
    musa.demir created

    Hi @Daniel

    Can you please check your job's args in sql

  • User Avatar
    0
    DanielNikolic created

    @musa.demir

    Here is a screenshot:

    {"TenantId":1,"BinaryObjectId":"37e2cae1-14f4-a459-29a4-3a005f09f090","User":{"TenantId":1,"UserId":2}}

    It has been called inside the default tenant with the admin account

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @DanielNikolic

    Could you share your ABP NuGet package version ? If it is 6.3, could you upgrade it to 6.3.1 at least and try again ?

    Thanks,

  • User Avatar
    0
    DanielNikolic created

    @ismcagdas

    My ABP version was indeed 6.3, I've upgraded it to 6.3.1 and ExecuteAsync seems to be called correctly now!