2

I'm using RabbitMq as one-way transport for a topic exchange

I configure timeouts to use external manager called "timeout.queue" in RabbitMq (which I had to create manually):

configurer.UseExternalTimeoutManager("timeout.queue")

This is how a send a message to defer:

var timeToSchedule = TimeSpan.FromSeconds(timeToScheduleInSeconds);

var headers = new Dictionary<string, string>
{
    { Headers.DeferredRecipient, "demo.consumer" },
    { Headers.ReturnAddress, "demo.consumer" }
};

await _bus.Defer(timeToSchedule, new EntityScheduled(), headers);

The problem is that when I defer the message, it's just kept in the timeout queue and no forwarding occurs.

I've been playing around with the headers too but not getting success.

"demo.consumer" is a queue bound to my intended topic exchange "defer.topic"

1 Answers1

1

My guess is that you've forgotten a vital piece of your infrastructure: The "timeout manager".

With Rebus, a "timeout manager" is a normal Rebus endpoint that has a timeout storage configured

Configure.With(...)
    .(...)
    .Timeouts(t => t.StoreIn(...))
    .(...)

e.g.

const string localDb = "server=.; database=rebus; trusted_connection=true";

Configure.With(...)
    .(...)
    .Timeouts(t => t.StoreInSqlServer(localDb, "RebusTimeouts"))
    .(...)

In your case, it would be something like this:

const string localDb = "server=.; database=rebus; trusted_connection=true";

Configure.With(...)
    .Transport(t => t.UseRabbitMq(rabbitConn, "timeout.queue"))
    .Timeouts(t => t.StoreInSqlServer(localDb, "RebusTimeouts"))
    .(...)

With a timeout manager installed, I bet your deferred messages will be sent as they should.

mookid8000
  • 18,258
  • 2
  • 39
  • 63
  • I'm configuring it to use an external one. Currently, it uses a new queue called "timeout.queue" in RabbitMq as described above – Edson Flores Palma Mar 06 '19 at 16:30
  • 1
    Ok. Which endpoint then receives messages from the `timeout.queue` queue? (hint: You need to set up a Rebus endpoint that does that and you don't add any message handlers to it, because all it's supposed to do is handle deferred messages) – mookid8000 Mar 06 '19 at 16:32
  • 1
    Oh I see, didn't understand that piece completely. Thank you! – Edson Flores Palma Mar 06 '19 at 17:00