Hopefully it will help someone else too.
You can get the source and binaries from github
https://github.com/andrevdm/TrivialMongoMessageQueue
Below is the readme from the project
----------------------------------------
TmMq
TmMq - Trivial MongoDB Message Queue is a very simple .net message queuing system built on MongoDBIt is not in any way meant to compete with any of the fully fledged messaging solutions (Hortet, ActiveMQ etc) but it is a nice, lightweight alternative that has proved useful to me.
Features
- No TmMq server
- Send & receive
- Publish / subscribe
- Redeliver on error with limit on retry
- Limit on delivery (at-least-once delivery)
- Message expiry
- Message holding (only deliver in future)
- Errors logged in message
- Dynamic properties collection
- Synchronous and asynchronous receive
- Written in C#
TODO
- Triggers based on tailable MongoDB cursor. I'm not sure this is necessary, I will implement it if I find I need it.
- More unit tests
Licence
FreeBSD License. See licence.txtUsage
See the unit tests for examples of all the features including pub/sub, retry, errors etc.Send & receive
using( var send = new TmMqSender( "TestSendBeforeReceiveStarted" ) )
{
var msg = new TmMqMessage();
msg.Text = "msg1";
send.Send( msg );
}
using( var recv = new TmMqReceiver( "TestSendBeforeReceiveStarted" ) )
{
ITmMqMessage recieved = recv.Receive().FirstOrDefault();
}
Pub/sub
using( var rcvr1 = new TmMqPubSubReceiver( "TestPubSub" ) )
using( var rcvr2 = new TmMqPubSubReceiver( "TestPubSub" ) )
using( var rcvr3 = new TmMqPubSubReceiver( "TestPubSub" ) )
using( var rcvr4 = new TmMqPubSubReceiver( "TestPubSub" ) )
{
var r1 = new List();
var r2 = new List();
var r3 = new List();
var r4 = new List();
rcvr1.StartReceiving( 1, r1.Add );
rcvr2.StartReceiving( 1, r2.Add );
rcvr3.StartReceiving( 1, r3.Add );
rcvr4.StartReceiving( 1, r4.Add );
using( var sender = new TmMqPubSubSender( "TestPubSub" ) )
{
var msg = new TmMqMessage();
msg.Text = "ps-" + i;
sender.Send( msg );
}
No comments:
Post a Comment