I been working on an OrmLite based Messaging implementation this weekend. Its still a work in progress, but is working against Sqlite and SqlServer2012 so far, in single pass. Still need to get the background worker implemented. https://gist.github.com/rsafier/a54b0af50518a6c8e9b5
.
I found this Extention method to be effective in dealing with the dynamic table names I required:
static object ExecWithAlias<T>(string table, Func<object> fn)
{
var modelDef = typeof(T).GetModelMetadata();
lock (modelDef)
{
var hold = modelDef.Alias;
try
{
modelDef.Alias = table;
return fn();
}
finally
{
modelDef.Alias = hold;
}
}
}
But initially I trying to make each queue/table name a distinct type so there would be no locking necessary. As written Message
is locked to a single operation at an instant because the other code will block. Its not a big deal for my current usage, it easily is running a few hundred messages per second. I was wondering if I was overlooking a better way of “cloning” a type.