I feel like I didn't fully understand how Rebus works...
I have a system where an API should queue messages in a SQL table, and a Worker Service that will do the processing of the messages. I noticed that the publisher tries to route the messages to a handler and if it does not find a proper handler it raises an exception and moves the message to the error queue... I just want my API to queue the message and let the Worker Service to get the message when ready...
My API configuration is:
services.AddRebus((configure) => configure
.Logging(l => l.NLog())
.Transport(t => t.UseSqlServer(transportOptions, "QueueMsgs"))
.Options(o => o.SetNumberOfWorkers(1))
.Options(o => o.SimpleRetryStrategy(maxDeliveryAttempts: 10))
);
And I try to send messages like:
await _bus.Send(user);
If I debug the Worker Service at the same time, everything works perfectly, but my goal is to not need the Worker Service to be active to keep the messages in the queue...
What can I do?
I tried to use publish to queue the message
await _bus.Publish(user);
And adding the Subscription:
services.AddRebus((configure) => configure
.Logging(l => l.NLog())
.Transport(t => t.UseSqlServer(transportOptions, "QueueMsgs"))
.Options(o => o.SetNumberOfWorkers(1))
.Options(o => o.SimpleRetryStrategy(maxDeliveryAttempts: 10))
.Subscriptions(s => s.StoreInSqlServer(sqlConnectionString, "QueueMsgsSubs"))
//.Options(o => )
);
I'm quite lost, to be honest.
Please any help will be highly appreciated. Thank you!!
As I suspected, the fault was on me, I didn't have the correct configuration:
This is for the service configuration:
And we need to send messages with .Send:
And that's it. Now my messages are nice and comfy waiting for the consumer to get them :)