First way of using Rebus’ timeout service is to use the default choice, which is the external timeout service. The external timeout service is a Windows service, that you can install – preferably one on each server in your environment – and leave there, running forever.
The timeout service will receive your TimeoutRequests, store them somewhere (preferably in a database of some kind), and then send them back as a TimeoutReply when the timeout has expired.
To get up and running, you can do this:
Get the Rebus source code and build the timeout service
1 2 3 |
C:\code> git clone git@github.com:mookid8000/Rebus.git C:\code> cd Rebus C:\code\Rebus> build_timeout |
and then go to /Rebus/deploy/NET40/Timeout where you’ll find the binaries.
Configure the timeout service
Currently, the timeout service can store its timeouts in memory, in SQL server, and in MongoDB. The timeout service can be configured by opening up Rebus.Timeout.exe.config and editing the timeout element – e.g. you might write something like this:
1 2 3 |
<timeout inputQueue="rebus.timeout" errorQueue="error" storageType="SQL" connectionString="server=.;initial catalog=RebusTimeoutManager;integrated security=sspi" tableName="timeouts" /> |
or this
1 2 3 |
<timeout inputQueue="rebus.timeout" errorQueue="error" storageType="mongodb" connectionString="mongodb://localhost/SomeDatabase" tableName="timeouts" /> |
depending on your preferences.
Install the service
In an administrator command prompt:
1 |
C:\Runnables\RebusTimeoutService> Rebus.Timeout.exe install |
and then, since rebus.timeout is the default queue name for the timeout service, all other local Rebus services can now bus.Defer(toTheFuture, theirMessages).
In the next post, I’ll explain how to configure Rebus to use the internal timeout service.