ReviewMass Transit Samples
Yesterday I reviewed Mass Transit itself, unfortunately, I missed the samples folder, which means that I didn't get critical information about how to use Mass Transit. I am going to do the same review for the samples, trying to get a feeling for how using Mass Transit feels.
Audit
This seems to be only partially done, it apparently should show how we can fire off events using Mass Transit. Again, I am impress by how simple the Cunsumes<TMsg>.All makes the code, but there is nothing there as of now.
Heavy Load
Load testing, not something that I am particularly interested at right this moment.
Publish Subscribe
This example more or less show how you can use Pub / Sub. Nothing really interesting there, but it has cleared my mind about a few things. Specifically, I was bothered by the tie of the service bus to a specific end point. What I missed was that this was the entry point end point, and that communication can (and does) flow to other end points. Once I grasped that, it became much easier to understand what was going on there.
What really bothers me, however, is this:
<component id="serviceBus" lifestyle="singleton" service="MassTransit.ServiceBus.IServiceBus, MassTransit.ServiceBus" type="MassTransit.ServiceBus.ServiceBus, MassTransit.ServiceBus"> <parameters> <endpointToListenOn>${serverEndpoint}</endpointToListenOn> <!-- Setter Injection --> <SubscriptionCache>${subscriptionCache}</SubscriptionCache> </parameters> </component> <component id="serverEndpoint" lifestyle="singleton" service="MassTransit.ServiceBus.IEndpoint, MassTransit.ServiceBus" type="MassTransit.ServiceBus.MSMQ.MsmqEndpoint, MassTransit.ServiceBus.MSMQ"> <parameters> <uriString>msmq://localhost/test_server</uriString> </parameters> </component>
That sound you just heard was me, fleeing in terror. The idea that I would need to write so much XML is abhorrent to me. My idea syntax would be something like this:
facility MassTransitFacility, startable = true: standardCustomersServiceBus = "msmq://localhost/standard_customers" enterpriseCustomersServiceBus = "msmq://localhost/enterprise_customers"extend OrdersController: standardCustomerPublisher = @standardCustomersServiceBus enterpriseCustomersPublisher = @enterpriseCustomersServiceBus
And this will allow us to define both service bus and the end points in the container, and start them as soon as they are ready. No need to do anything in the actual application code beyond just creating the container.
Web Request Reply
This is very interesting, because it shows how you can handle request reply scenarios, which are very common in data handling scenarios. In this case, the code sample show an async request / reply, using MonoRail's async actions:
public IAsyncResult BeginAsync(string requestText) { _request = _bus.Request() .From(this) .WithCallback(ControllerContext.Async.Callback, ControllerContext.Async.State) .Send(new RequestMessage(CorrelationId, requestText)); return _request; } public void EndAsync() { PropertyBag.Add("responseText", msg.Text + " (and my response)"); RenderView("Default"); } public void Consume(ResponseMessage message) { msg = message; _request.Complete(); }
I find it very nice. I did wonder at first how the standard EndSend() is involved here, but then I realized that it is not. It doesn't make sense for message passing semantics. When you pass the this pointer to the From() method, it will register that for accepting messages from the bus. I do wonder about such things as timeouts and memory leaks. From my observation, a failure in handling the response of a message would leak the handler instance.
To conclude, after reviewing the samples, I feel that I have a much better understanding of Mass Transit, which is good. It hasn't shifted my thinking, the way reading NServiceBus did, but that is probably because I have already read NServiceBus code.
Comments
You know, I have an in-house framework that turns out to be very similar to NSB (it either hadn't been released yet or I just didn't know of it, otherwise I probably wouldn't have rolled my own) that I've been thinking of open sourcing. If you ever seriously consider going your own way, send me an email, and if I can't contribute that code directly, I'd at least love to be involved.
whoops, left out a key part: that in-house framework makes use of castle pretty heavily - it uses windsor for ioc, and we've built a couple of custom facilities for things like MSMQ queue management and as a configuration pseudo-DSL. however, in terms of feature breadth, it's v .5 to NSB's v5.
I would like to see the code, the most aspects on this that I can see, the better.
Comment preview