Hi,
You can see in the prior example we are throwing a test exception in the WebhookPublishProductFieldApproved
class which throws this:
throw new System.Exception("test from background job");
It runs in the background. We want to handle any exception that are thrown in the background.
Below is the ProductFieldApprovedEventData
class
public class ProductFieldApprovedEventData : WebhookEventData
{
public int ProductId { get; set; }
public int ProductDetailId { get; set; }
}
public class WebhookEventData : EventData
{
public SchemaTypeEnum SchemaType { get; set; }
}
Thank you
Hi @ismcagdas and thank you for the reply.
In most cases we don't catch the exceptions, we rely on the framework to handle this for us. In the case of background jobs we are depending on the exceptions details getting logged to the Audit log. We are trying to add functionality to send a notification whenever an exception is thrown. However, we are not receiving any events through AbpHandledExceptionData for background jobs wo no notifications are being sent nor are they logged in the audit log. It works for everything else. Below is an example of the workflow.
Enqueueing event:
// _backgroundJobManager is IBackgroundJobManager injected into an AppService's constructor.
await _backgroundJobManager.EnqueueEventAsync(new ProductFieldApprovedEventData
{
// properties
});
Handling event and throwing the exception inside:
public class WebhookPublishProductFieldApproved : ISingletonDependency, IAsyncEventHandler<ProductFieldApprovedEventData>
{
// other dependencies
public async Task HandleEventAsync(ProductFieldApprovedEventData eventData)
{
throw new System.Exception("test from background job"); // cannot catch this later using handlers
// actual logic for this event's handling
}
}
Handling the exception event:
public class ExceptionWebhookEventHandler : ISingletonDependency, IAsyncEventHandler<AbpHandledExceptionData>
{
// other dependencies
public async Task HandleEventAsync(AbpHandledExceptionData eventData)
{
// handling logic using eventData.Exception
}
}
We are implementing custom exception handling for our project.
We've implemented IAsyncEventHandler<AbpHandledExceptionData>
for AppServices and IAsyncExceptionFilter
for Controllers and everything works fine, these areas are covered.
We also have a lot of IAsyncEventHandler
governed by hangfire for different background events.
The problem is that if an exception occurs inside HandleEventAsync
, neither handler nor filter get triggered.
Is there any way to handle these exceptions?
We have tried following (nothing worked):
ExceptionFilterAttribute
and attaching it to the instance of IAsyncExceptionFilter
, attribute never gets called.AbpHandledExceptionData
, never gets called.EntityCreatedEventData<AuditLog>
doesn't work because audit log is not written in this case.EntityCreatedEventData<SqlJob>
doesn't work because Hangfire.SqlJob
is not public like audit log.Startup:
services.AddHangfire(config =>
{
config.UseSqlServerStorage(_appConfiguration.GetConnectionString("Default"));
config.UseFilter(new AutomaticRetryAttribute
{
Attempts = 2,
OnAttemptsExceeded = AttemptsExceededAction.Fail,
LogEvents = true,
});
config.UseLogProvider(new CustomLog4NetLogProvider()); // doesn't work
});
Custom logger:
public class CustomLog4NetLogProvider : Log4NetLogProvider
{
public new ILog GetLogger(string name)
{
return new CustomLog4NetLogger(base.GetLogger(name));
}
}
public class CustomLog4NetLogger : ILog
{
private readonly ILog _baseLogger;
public CustomLog4NetLogger(ILog baseLogger)
{
_baseLogger = baseLogger;
}
public bool Log(LogLevel logLevel, Func<string> messageFunc, Exception exception = null)
{
// do something
return _baseLogger.Log(logLevel, messageFunc, exception);
}
}
Hi, I am looking to update rows in a table that is Audited but in this specific instance I want to update the data and prevent the LastModifierUserId, LastModificationTime columns from being automatically updated. I also would like to prevent the ABP Entity Change tables from logging the change. Is it possible to turn off auditing as needed on a per method basis?
Thank you
Turns out version 8.9.2 didn't encrypt the setting Abp.Zero.Ldap.Password and version 11.1 does. I wasn't getting the cryptography error until I enabled all exceptions. Removing the old value and entering it using the GUI solved the issue.
Hi @ismcagdas
It happens at startup, which prevents the app from starting. We get "HTTP Error 500.30 - ASP.NET Core app failed to start"
I took a fresh copy that I downloaded of AspNetZero v11.1 of our project and pointed it to the version 8.9.2 database. I ran migrations to update the DB schema. Finally I disabled multi tenancy and ran the application.
I was able to recreate the issue. So it doesnt like something in the Database, which is odd because we have multi tenancy disabled in the 8.9.2 version.
Do you have any idea what area of the DB we should start looking for the issue?
Thank you.
Setting MultiTenancyEnabled = false causes "System.FormatException: 'The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.'" error in startup.cs > app.UseAbpRequestLocalization();
It works find if we leave Multi Tenancy Enabled.
Background: We are upgrading our project's from AspNetZero 8.9.2 to 11.1.
Any help is appreciated.
Hi,
My product version is ASP.NET CORE MVC & jQuery .NET Core 3.1 v9.0.0
How would we add an Active Directory Group to an ABP Role and have it grant the appropriate permissions?
Thanks, Ron
Hello,
I feel like it would be invaluable to the community if we could have access to the source code of the Power Tools to customize it to meet our constantly changing needs. I believe the VC RAD tool is already on Github, so it seems like this should be available as well.
Are there any plans to release it in a private repo on Github?
Thanks, Ron
Done!
https://github.com/aspnetzero/aspnet-zero-core/issues/2935