You mean stop using
transactionProcessingJob : AsyncBackgroundJob<TArgs>
??
Hi,
I had already tried something with BackgroundJob
before I posted, I just couldn't get it to work and Is till don't understand how to apply this. In essence a class that processes a type of job
public class TransactionProcessingJob : AsyncBackgroundJob<TransactionProcessingArgs>, ITransientDependency
has method
public override async Task ExecuteAsync(TransactionProcessingArgs args)
{
try
{
IUnitOfWorkManager unitOfWorkManager = _serviceProvider.GetRequiredService<IUnitOfWorkManager>();
using (unitOfWorkManager.Begin())
{
// stuff in here
}
}
catch (Exception ex)
{
Logger.LogError(ex, "Unable to process transaction {TransactionId}", args.TranId);
await _emailSender.QueueAsync(
to: _config["Notifications:Recipients"],
subject: $"Error processing transaction {args.TranId} {args.Channel} {args.ObjectType} {args.ExternalID} for Tenant: {tenantId}",
body: $"{ex.Message}</br>{ex.InnerException?.Message}"
);
using (_currentTenant.Change(tenantId != default ? tenantId : null))
{
var transaction = await _transactionRepository.GetAsync(args.TranId);
transaction.Error = $"{ex.Message}\n{ex?.InnerException?.Message}";
await _transactionRepository.UpdateAsync(transaction);
}
throw;
}
}
In the catch block, it'd be nice to capture job id and set it on a property of the transaction, this way from a dashboard page, using TransactionAppService
The user can retry that transaction.
I had already tried to do this adapating an implementation in one of the modules that grabs a distributed lock and IBackgroundJobStore
to use FindAsync(guid) to retrieve the job, but since I don't have the job id I can't use IBackgroundJobExecuter
to execute the job.
Hi Maliming,
Thanks for feedback, yes I did that before opening ticket.
<PackageReference Include="Volo.Abp.LeptonTheme.Management.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Autofac" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="7.1.1" /> <PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Swashbuckle" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.Domain" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Public.Web.OpenIddict" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Public.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Public.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Admin.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Admin.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Admin.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AuditLogging.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.OpenIddict.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Saas.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Saas.Host.Application" Version="7.1.1" /> <PackageReference Include="Volo.Saas.Host.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.BlobStoring.Database.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Autofac.WebAssembly" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Components.WebAssembly.LeptonTheme" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.Blazor.WebAssembly" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.Blazor.WebAssembly" Version="7.1.1" /> <PackageReference Include="Volo.Saas.Host.Blazor.WebAssembly" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.Blazor.WebAssembly" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Admin.Blazor.WebAssembly" Version="7.1.1" /> <PackageReference Include="Volo.Abp.OpenIddict.Pro.Blazor.WebAssembly" Version="7.1.1" /> <PackageReference Include="Volo.Abp.TextTemplateManagement.Blazor.WebAssembly" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AuditLogging.Blazor.WebAssembly" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LanguageManagement.Blazor.WebAssembly" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Autofac" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Components.Server.LeptonTheme" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.Blazor.Server" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.Domain" Version="7.1.1" /> <PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Swashbuckle" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AuditLogging.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Public.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Public.Web.OpenIddict" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Admin.Blazor.Server" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Admin.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.Blazor.Server" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.Blazor.Server" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.Blazor.Server" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Saas.Host.Blazor.Server" Version="7.1.1" /> <PackageReference Include="Volo.Saas.Host.Application" Version="7.1.1" /> <PackageReference Include="Volo.Saas.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.BlobStoring.Database.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Commercial.SuiteTemplates" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Autofac" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="7.1.1" /> <PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Swashbuckle" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AuditLogging.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Saas.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.Domain" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Autofac" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.Client" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Authentication.OpenIdConnect" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Http.Client.IdentityModel.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Http.Client.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Swashbuckle" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.HttpApi.Client" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Admin.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Public.HttpApi.Client" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.HttpApi.Client" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.HttpApi.Client" Version="7.1.1" /> <PackageReference Include="Volo.Saas.Host.Web" Version="7.1.1" /> <PackageReference Include="Volo.Saas.Host.HttpApi.Client" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.HttpApi.Client" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Autofac" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.LeptonTheme.Management.Domain" Version="7.1.1" /> <PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Swashbuckle" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AuditLogging.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AuditLogging.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AuditLogging.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AuditLogging.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Public.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Public.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Public.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Admin.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Admin.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Account.Pro.Admin.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.SettingManagement.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Identity.Pro.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.Web" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Saas.Host.Web" Version="7.1.1" /> <PackageReference Include="Volo.Saas.Host.Application" Version="7.1.1" /> <PackageReference Include="Volo.Saas.Host.HttpApi" Version="7.1.1" /> <PackageReference Include="Volo.Saas.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.BlobStoring.Database.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Authorization.Abstractions" Version="7.1.1" /> <PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="7.1.1" /> <PackageReference Include="Volo.Abp.BackgroundJobs.HangFire" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Ddd.Application" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AutoMapper" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Emailing" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Components.Server.Theming" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Components.WebAssembly.Theming" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AutoMapper" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Components.Web.Theming" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Validation" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Ddd.Domain" Version="7.1.1" /> <PackageReference Include="Volo.Abp.EntityFrameworkCore" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Http.Client" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="7.1.1" /> <PackageReference Include="Volo.Abp.MongoDB" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AutoMapper" Version="7.1.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared" Version="7.1.1" /> <PackageReference Include="Volo.Abp.EntityFrameworkCore.Sqlite" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Autofac" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Autofac" Version="7.1.1" /> <PackageReference Include="Volo.Abp.Authorization" Version="7.1.1" /> <PackageReference Include="Volo.Abp.TestBase" Version="7.1.1" />
Seems although there was no error popping up I needed to implement this patch for chrome https://community.abp.io/posts/patch-for-chrome-login-issue-identityserver4-samesite-cookie-problem-weypwp3n
After that login was possible on blazor side but angular had a refresh loop, the console shows error regarding mixed content being blocked, so adding this to the head in index.html of angular app resolved.
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
using blazor server for the main admin application, also an angular application
I did indeed use the middleware.
app.Use(async (ctx, next) =>
{
var configuration = ctx.RequestServices.GetRequiredService<IConfiguration>();
ctx.SetIdentityServerOrigin(configuration["App:SelfUrl"]);
await next();
});
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
app.UseHttpsRedirection();
For more context:
I've tried running the solution in docker with the auth server behind an nginx load balancer.
server {
listen 443 ssl;
server_name blazor.mydomain.com;
ssl_certificate /etc/nginx/certs/app-cert.pem;
ssl_certificate_key /etc/nginx/certs/app-cert-key.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://blazorapp;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Configuration for WebSockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_cache off;
# WebSockets were implemented after http/1.0
proxy_http_version 1.1;
# Configuration for ServerSentEvents
proxy_buffering off;
# Configuration for LongPolling or if your KeepAliveInterval is longer than 60 seconds
proxy_read_timeout 100s;
}
location /signalr-hubs {
proxy_pass http://blazorapp;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /wsapp/ {
proxy_pass http://blazorapp;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_buffering off;
}
}
Added this per Microsoft documentation https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-6.0#forwarded-headers-middleware-order to the blazormodule
private void ConfigureForwardedHeaders(ServiceConfigurationContext context)
{
context.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
....
app.Use(async (ctx, next) =>
{
var configuration = ctx.RequestServices.GetRequiredService<IConfiguration>();
ctx.SetIdentityServerOrigin(configuration["App:SelfUrl"]);
await next();
});
....
}
Trying to log in from the blazor app, it seems the login process succeeds but when it returns to the main page, it is not logged in.
Trying to log in on the angular side the login page just refreshes after clicking log in
The only thing i see in the log is below but im not sure this is relevant
hello support, would you take a look at a project? Do you have a guide that shows the settings between prod and dev operational for us new devs?
Hi gterdem,
I had already tried the strictdiscoverydocumentvalidation one but not the skipissuercheck. When I use skipissuercheck it does not throw the error but it just doesnt go to the identity server login page. anything else i need to check ?
The issue turned out to be use of async via AsyncHelper.RunSync in a singleton constructor: my bad.
Thanks!
Hi Liang,
Yes the recurring worker jobs are okay, in my sample i triggered queued for processing various non-recurring worker jobs that take TransactionProcessingArgs. You can see in the screenshots above, maybe trigger a bunch of these. You should get failures since you dont have keys to use the domain service and these will end up in retry states. Stop the application and try again? Any time I have jobs in the hangfire.jobs table it wouldnt start back up