使用Redis的Hangfire.Console似乎不起作用

时间:2017-04-19 14:12:29

标签: logging redis hangfire

我想将Hangfire.Console与Redis一起使用,但它似乎无法正常工作。

我有以下配置代码:

GlobalConfiguration.Configuration
    .UseRedisStorage(RedisMultiplexer)
    .UseConsole();

JobMethod:

public void AddLatestDocsToIndex(PerformContext context)
{
    var lastId = this.GetIdsByIndexerConfiguration(this.IndexerConfigurations["GetLastDocIdFromIndex"]).FirstOrDefault();
    var models = TransactionEntityModel.GetBiggerThanId(lastId);
    if (!models.Any())
    {
        context.WriteLine("No new documents found.");
        return;
    }
    var helper = new SearchHelper<TransactionEntityConfiguration, TransactionEntityModel>();
    helper.AddOrUpdateBulk(models);
    context.WriteLine($"Added {models.Count} document(s) to the index.");
}

Hangfire重复工作电话:

RecurringJob.AddOrUpdate<TransactionEntityConfiguration>(
    "TransactionLatestDocsIndexer",
    x => x.AddLatestDocsToIndex(null),              
    Cron.MinuteInterval(5));

在信息中心中,我没有看到任何记录消息。此外,当我查看Redis时,日志消息不会显示在任何地方。

我正在使用以下软件包和版本:

<package id="Hangfire" version="1.6.12" targetFramework="net451" />
<package id="Hangfire.Console" version="1.3.1" targetFramework="net451" />
<package id="Hangfire.Core" version="1.6.12" targetFramework="net451" />
<package id="Hangfire.Redis.StackExchange" version="1.6.7.24" targetFramework="net451" />

我做错了吗?

提前致谢。

0 个答案:

没有答案