Latest Replies
Thursday
Sep012011

.NET Sample of Marrying CQRS, JS, and Http

We've just published a rather interesting .NET code sample illustrating interactions between a browser and a CQRS-like server with queue processing. The sample is implemented as a snippet on top of Lokad.Cqrs, leveraging the latest codebase and new http endpoint functionality.

Just a reminder. Lokad.Cqrs is not a real framework. It is just a temp scaffolding that speeds up development of distributed systems following CQRS architecture principles. It enforces design that will make it easy to scale and move system between on-premises and cloud deployments (saving money, whenever possible). Core elements are made intentionally simple to educate and encourage eventually replacing them with solutions tailored specifically for the specific project.

HttpEndpoint is a new feature of Lokad.Cqrs, that demonstrates how easy it is to write some simple non-blocking web server and then put it to a good use. In the sample we do some interesting stuff:

  • host both CQRS engine and http server in the same process;
  • actually start the entire process inside a unit test;
  • serve some html, images and javascript to the web browser (tested with all major ones :)
  • let browser post simplified commands to the memory queue on the server;
  • process these commands in async, aggregating results to a simple view;
  • use this view to display info back in the web browser.

Sounds cool enough for a simple sample? Here's how it actually looks like:

You drag Lokad.CQRS logo around the canvas. Each mouse move generates an event, which is AJAX posted to HttpEndpoint, which adds a message to the queue. Another javascript queries a view for the stats like distance and average message throughput of this non-optimized code.

Interested to see how simple this code is? It is shared with the community as open source within the Lokad.Cqrs/Snippets project in hope that it will be of any help. You can:

  • Check out ReadMe or just grab Lokad.CQRS (branch 'vnext') from github and run it locally.
  • Ask questions in our community.

BTW, the primary reasons, why HttpEndpoint functionality was added to Lokad.Cqrs were about supporting following simple scenarios:

  • network message dispatch in non-Azure deployments of systems developed with Lokad.Cqrs;
  • simple secure endpoints for posting commands and querying views (problem of long lists can be solved here);
  • extremely simple built-in UI for certain maintenance scenarios in Lokad.Cqrs systems that should work nicely even with fast push deployments on Azure;
  • an easy way to support XML/REST/JSON integration scenarios with 3rd party systems without the need to roll out ASMX/WCF/ASP.NET or whatever over-complicated mess.
  • have all these endpoints (supporting multiple virtual urls on a single server) on the same machine with the server processes, saving money on small project deployments in the cloud.

What do you think of this sample?

« Update on CQRS/ES Trip Across Ukraine in October | Main | Mindsets in development: Enterprise vs Startup »

Reader Comments (2)

This is great timing, I was just starting to play around with lokad and other cqrs frameworks. Thanks for all of your time with this and the podcast.

September 2, 2011 | Unregistered CommenterJosh

Thanks, Josh. I guess I still owe everybody a bigger-picture explanation of where we are taking Lokad.CQRS.

September 3, 2011 | Registered CommenterRinat Abdullin

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>