We are using Rebus as a queue system with Sql server. We have several recipients for different types of messages. Each message can be handled by several workers of a certain type. One message should only be handled/processed by one worker (the first one that pulls it). If a worker for some reason can't finish it, it postpones the message using the timeout service.
If I have understood it correctly, it becomes a TimeoutRequest and put in the timeouts table. When it's time to rerun, it becomes a TimeoutReply before it is reintroduced into the queue as the original message.
The problem we are having is that when it becomes a TimeoutReply, all the workers pick it up and create the original message. One original message becomes several messages (as many as there are workers) when timed out.
Our Rebus setup is the following:
"Server side":
var adapter = new BuiltinContainerAdapter();
Configure.With(adapter)
.Logging(l => l.Log4Net())
.Transport(t => t.UseSqlServerInOneWayClientMode(connectionString).EnsureTableIsCreated())
.CreateBus()
.Start();
return adapter;
"Worker side":
_adapter = new BuiltinContainerAdapter();
Configure.With(_adapter)
.Logging(l => l.Log4Net())
.Transport(t => t.UseSqlServer(_connectionString, _inputQueue, "error")
.EnsureTableIsCreated())
.Events(x => x.AfterMessage += ((bus, exception, message) => SendWorkerFinishedJob(exception, message)))
.Events(x => x.BeforeMessage += (bus, message) => SignalWorkerStartedJob(message))
.Behavior(x => x.SetMaxRetriesFor<Exception>(0))
.Timeouts(x => x.StoreInSqlServer(_connectionString, "timeouts").EnsureTableIsCreated())
.CreateBus().Start(numberOfWorkers);
Any help in solving the problem or to provide understanding is greatly appreciated!