Did you build it in Release mode as that is needed to activate the mentioned code? Will build fine in debug mode but not in Release mode as AccessTokenKey isn't declared.
Ok, i will try
Hi,
I will fix it in the next patch version. You can try this
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IBackgroundWorkerManager), typeof(HangfireBackgroundWorkerManager))]
public class MyHangfireBackgroundWorkerManager : HangfireBackgroundWorkerManager
{
public MyHangfireBackgroundWorkerManager(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
public override async Task AddAsync(IBackgroundWorker worker, CancellationToken cancellationToken = default)
{
switch (worker)
{
case IHangfireBackgroundWorker hangfireBackgroundWorker:
{
var unProxyWorker = ProxyHelper.UnProxy(hangfireBackgroundWorker);
if (hangfireBackgroundWorker.RecurringJobId.IsNullOrWhiteSpace())
{
RecurringJob.AddOrUpdate(
() => ((IHangfireBackgroundWorker)unProxyWorker).DoWorkAsync(cancellationToken),
hangfireBackgroundWorker.CronExpression, hangfireBackgroundWorker.TimeZone,
hangfireBackgroundWorker.Queue);
}
else
{
RecurringJob.AddOrUpdate(hangfireBackgroundWorker.RecurringJobId,
() => ((IHangfireBackgroundWorker)unProxyWorker).DoWorkAsync(cancellationToken),
hangfireBackgroundWorker.CronExpression, hangfireBackgroundWorker.TimeZone,
hangfireBackgroundWorker.Queue);
}
break;
}
case AsyncPeriodicBackgroundWorkerBase or PeriodicBackgroundWorkerBase:
{
var timer = worker.GetType()
.GetProperty("Timer", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(worker);
var period = worker is AsyncPeriodicBackgroundWorkerBase
? ((AbpAsyncTimer?)timer)?.Period
: ((AbpTimer?)timer)?.Period;
if (period == null)
{
return;
}
var unProxiedType = ProxyHelper.GetUnProxiedType(worker);
var adapterType =
typeof(HangfirePeriodicBackgroundWorkerAdapter<>).MakeGenericType(unProxiedType);
var workerAdapter = (Activator.CreateInstance(adapterType) as IHangfireBackgroundWorker)!;
RecurringJob.AddOrUpdate(unProxiedType.Name, () => workerAdapter.DoWorkAsync(cancellationToken), GetCron(period.Value),
workerAdapter.TimeZone, workerAdapter.Queue);
break;
}
default:
await base.AddAsync(worker, cancellationToken);
break;
}
}
protected override string GetCron(int period)
{
var time = TimeSpan.FromMilliseconds(period);
string cron;
if (time.TotalSeconds <= 59)
{
cron = $"*/{time.TotalSeconds} * * * * *";
}
else if (time.TotalMinutes <= 59)
{
cron = $"*/{time.TotalMinutes} * * * *";
}
else if (time.TotalHours <= 23)
{
cron = $"0 */{time.TotalHours} * * *";
}
else if(time.TotalDays <= 31)
{
cron = $"0 0 0 1/{time.TotalDays} * *";
}
else
{
throw new AbpException(
$"Cannot convert period: {period} to cron expression, use HangfireBackgroundWorkerBase to define worker");
}
return cron;
}
}
for example:
app.Use((httpContext, next) =>
{
var logger = httpContext.RequestServices.GetRequiredService<ILogger<YourModuleClass>>();
foreach (var header in httpContext.Request.Headers)
{
logger.LogInformation($"----------Request header: {header.Key}: {header.Value}----------");
}
return next();
});
i don't know
gateway project is enough.
if still not working you can add a middleware to output the HTTP request info to logs to see the request host.
Hi,
Sorry about that. We are fixing the problem.
your ticket was refunded.
Hi,
Sorry for that, we are fixing the problem.
ok, thanks for the info
Hi,
You can check the document
https://abp.io/docs/latest/solution-templates/microservice/adding-new-microservices#gsc.tab=0