Currently, ScriptCS.Rebus uses MSMQ as transport mechanism. In the latest release of ScriptCs.Rebus, I’ve included support for RabbitMQ and console logging.
RabbitMQ is a widely used and rock-solid messaging framework. In my original post, I outlined how to get started using ScriptCs and ScriptCs.Rebus in particular, I’ll therefore urge the reader to read that post prior to this one.
Besides major refactorings and code clean-up, the two main features of 0.3.0 is support for RabbitMQ and console logging.
Support for RabbitMQ
I’ve been very trying to be very consistent with the original design, and therefore configuring ScriptCs.Rebus for RabbitMQ is very straightforward:
Require<RebusScriptBus>() .ConfigureRabbitBus("MyMessageQueue") .Send<string>("Foo")
This will configure the bus to use the default RabbitMQ port, amqp://localhost:5672, which requires a local server. This configuration is equivalent to using ScriptCs.Rebus with MSMQ, with additional RabbitMQ features. Usually, a remote server is used, and to supply a connectionstring, use the following configuration:
Require<RebusScriptBus>() .ConfigureRabbitBus("MyMessageQueue", "amqp://remoteserver") .Send<string>("Foo")
With this configuration the message of type String will be sent to the remote server. Likewise when you to need receive messages from the remote server, configuration follow the same setup as of the one from MSMQ:
Require<RebusScriptBus>() .ConfigureRabbitBus("MyMessageQueue", "ampq://remoteserver") .Receive<string>(x => Console.WriteLine(x)) .Start()
Working with message busses can often be very complex and a blackbox. Since Rebus has a nice and very useful console logging, it makes so much sense to support this as an option for script authors. Console logging is available for both MSMQ and RabbitMQ busses. By default console logging is disabled. To enable console logging, just add UseLogging() to your configuration:
Require<RebusScriptBus>() .ConfigureBus("MyMessageQueue") .UseLogging() .Send<string>("Foo")
Now console logging is enabled and will output some nice logging like this:
Rebus.Configuration.RebusConfigurer DEBUG (): Defaulting to 'throwing endpoint mapper' - i.e. the bus will throw an exception when you send a message that is not explicitly routed Rebus.Configuration.RebusConfigurer DEBUG (): Defaulting to in-memory saga persister (should probably not be used for real) Rebus.Configuration.RebusConfigurer DEBUG (): Defaulting to in-memory subscription storage (should probably not be used for real) Rebus.Bus.RebusBus INFO (): Rebus bus 1 created Rebus.Bus.RebusBus INFO (): Using external timeout manager with input queue 'rebus.timeout' Rebus.Bus.RebusBus INFO (): Initializing bus with 1 workers Rebus.Bus.Worker INFO (): Worker Rebus 1 worker 1 created and inner thread started Rebus.Bus.Worker INFO (): Starting worker thread Rebus 1 worker 1 Rebus.Bus.RebusBus INFO (): Bus started Sending message of type String... Rebus.Logging.MessageLogger DEBUG (): Sending Foo to MyMessageQueue ... message sent.
That’s it for 0.3.0, get it, use it, and let me know what you think of it.Tweet
comments powered by Disqus