hangfire - 将多个hangfire实例与单个postgresql数据库一起使用,如何写代码
你可以使用Hangfire.PostgreSql这个第三方包来设置多个Hangfire实例,以及将它们连接到同一个PostgreSQL数据库。要设置多个Hangfire实例,你需要像这样写代码:
// Configure Hangfire for the first instance
var storageOptions = new PostgreSqlStorageOptions {
SchemaName = "hangfire1"
};
GlobalConfiguration.Configuration.UsePostgreSqlStorage("ConnectionString", storageOptions);
// Configure Hangfire for the second instance
storageOptions = new PostgreSqlStorageOptions {
SchemaName = "hangfire2"
}; GlobalConfiguration.Configuration.UsePostgreSqlStorage("ConnectionString", storageOptions);
免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。