Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Args for AsyncBackgroundJob #14863

Closed
1 task done
VivienMAN opened this issue Nov 28, 2022 · 5 comments
Closed
1 task done

Args for AsyncBackgroundJob #14863

VivienMAN opened this issue Nov 28, 2022 · 5 comments
Labels

Comments

@VivienMAN
Copy link

VivienMAN commented Nov 28, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Description

public class PhotoDoc : FullAuditedEntity<Guid>
    {
        [NotNull]
        public virtual string Name { get; set; }
     }

internal class SavingImageArgs {
  public PhotoDoc PhotoDoc {
    get;
    set;
  }
  public byte[] ImageAsByteArray {
    get;
    set;
  }
  public bool IsPhoto {
    get;
    set;
  }
}

internal class SavingImageJob: AsyncBackgroundJob < SavingImageArgs > , ITransientDependency {
  private readonly IBlobContainer < PhotoContainer > _blobContainer;

  public SavingImageJob(IBlobContainer < PhotoContainer > blobContainer) {
    _blobContainer = blobContainer;
  }

  public override async Task ExecuteAsync(SavingImageArgs args) {
    try {
      //code    
    } catch (Exception e) {
      throw e;
    }
  }
}

When we arrive in the ExecuteAsync method of the SavingImageJob class: AsyncBackgroundJob, ITransientDependency

The Id property of the PhotoDoc property is null.

While SavingImageArgs is correctly created.

Reproduction Steps

No response

Expected behavior

No response

Actual behavior

No response

Regression?

No response

Known Workarounds

No response

Version

6.0.0

User Interface

Blazor Server

Database Provider

EF Core (Default)

Tiered or separate authentication server

None (Default)

Operation System

Windows (Default)

Other information

No response

@VivienMAN VivienMAN added the bug label Nov 28, 2022
@berkansasmaz
Copy link
Member

Hi, as far as I understand your question doesn't seem like a bug. Try adding Id property to SavingImageArgs and setting it in the relevant place. Because SavingImageJob's ExecuteAsync method takes SavingImageArgs as an argument, it has nothing to do with PhotoDoc. See: https://docs.abp.io/en/abp/latest/Background-Jobs#create-a-background-job

@ghost
Copy link

ghost commented Nov 30, 2022

Hi,
Passing the GUID Id property to the job args to build or complete the PhotoDoc : FullAuditedEntity object later does work properly but feels awkward.
Our current issue is that passing a complete and correct PhotoDoc to the job arguments has the consequence of executing the job with a PhotoDoc element which has an incorrect Id (empty : 00000000-0000-0000-0000-000000000000).

It might be an intended feature to prevent duplication of a FullAuditedEntity, but we cannot see the reason clearly.

@berkansasmaz
Copy link
Member

I understand your problem now, if it's as you say it might be a problem. I will test this as soon as possible and get back to you. Thank you for the information you provided.

@berkansasmaz
Copy link
Member

I tested the situation with a no-layer template(v6.0.0), but unfortunately, I could not reproduce the problem as you mentioned.

Any chance of sending more information or minimal reproducible example to help me reproduce the problem?

@berkansasmaz
Copy link
Member

It has been determined that the problem is caused by the Id property having a protected setter. See more: #6095

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants