blehnen / DotNetWorkQueue

A work queue for dot.net with SQL server, SQLite, Redis and PostGreSQL backends

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue when consumer run

anhdhbn opened this issue · comments

I use redis db to save it. Queue job is oke job is saved in db, but when i start queue in consumer, it doesn't go to my function. Job in db still disappear in pending but it is appear in Error db. Here is my code.

    class Program
    {
        static void Main(string[] args)
        {
            using (var queueContainer = new QueueContainer<RedisQueueInit>())
            {
                string connectionString = "localhost:1234";
                using (var queue = queueContainer.CreateConsumer("tracking", connectionString))
                {
                    queue.Configuration.Worker.WorkerCount = 1;
                    Console.WriteLine(DateTime.Now);
                    queue.Start<dynamic>(Handle);
                    Console.WriteLine(DateTime.Now);
                    Console.WriteLine("Processing messages - press any key to stop");
                    Console.ReadKey((true));
                }
            }
        }

        public static void Handle(IReceivedMessage<dynamic> arg1, IWorkerNotification arg2)
        {
            // Not run to here
            Log.Logger.Information($"{DateTime.Now} Processing message {arg1.MessageId.Id.Value.ToString()}");
            Thread.Sleep(20000);
            Log.Logger.Information($"{DateTime.Now} Message {arg1.MessageId.Id.Value.ToString()} complete");
        }
    }

And here is log

20/08/2019 1:47:19 PM
20/08/2019 1:47:19 PM
Processing messages - press any key to stop

Please help me, thank you very much!

Hi,

My guess is that your getting an error on de-serialization.

Try wiring up a logger so that you can view the exception.

Here's how you would use serilog - add this at the top of your consumer entry point before creating the queue container

using Serilog;

var log = new LoggerConfiguration()
.WriteTo.Console()
.MinimumLevel.Debug()
.CreateLogger();
Log.Logger = log;

You would need to add Serilog and Serilog.Sinks.Console from Nuget