Is it possibe to use both storage (PostgreSQL and InMemory) in Hangfire?

586 views Asked by At

I'm trying to solve the problem when I wanna run jobs in two different ways, only for one service instance and for multiple services instances. So I decided to create two different queues and just keep "local" jobs in "local" queue and in memory(single instance) and keep "global" jobs in the "global" queue in PostgreSQL(multiple instances)

I have some problems with storage. I need two storages for two different queues. I need "Local" storage (InMemery for example) and "Global" storage (PostgreSQL) - the same name for queues. So when I try to register both storages in IoC I get only the last one. For example, PostgreSQL.

services.AddHangfire(
            configuration => configuration
                .UseSimpleAssemblyNameTypeSerializer()
                .UseRecommendedSerializerSettings()
                .UseInMemoryStorage()
                .UsePostgreSqlStorage(options.ConnectionString));

I think what ofc I can write my own storage will call "Hybrid", but that's a lot of work, maybe someone known how to solve that problem?

0

There are 0 answers