fissolue.SimpleQueue.FluentNHibernate 1.0.1

.NET Framework 4.5
Install-Package fissolue.SimpleQueue.FluentNHibernate -Version 1.0.1
dotnet add package fissolue.SimpleQueue.FluentNHibernate --version 1.0.1
<PackageReference Include="fissolue.SimpleQueue.FluentNHibernate" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add fissolue.SimpleQueue.FluentNHibernate --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: fissolue.SimpleQueue.FluentNHibernate, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install fissolue.SimpleQueue.FluentNHibernate as a Cake Addin
#addin nuget:?package=fissolue.SimpleQueue.FluentNHibernate&version=1.0.1

// Install fissolue.SimpleQueue.FluentNHibernate as a Cake Tool
#tool nuget:?package=fissolue.SimpleQueue.FluentNHibernate&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SimpleQueue - a simple database-backed queue implementation for .NET


SimpleQueue is a NuGet library that you can add in to your project that will allow you to persist objects into one or more queues. The current implementation is based on Fluent NHibernate, so you can use this implementation on top of all the databases NHibernate currently supports (MS SQL Server 2005 and above, Oracle, Microsoft Access, Firebird, PostgreSQL, DB2 UDB, MySQL, SQLite). An Entity Framework version is forthcoming.

You can decide the best way to persist the data - all have advantages and disadvantages. You can use .NET's binary serialization, serialization, the DataContractJsonSerializer, or XML. For binary serialization, any complex objects must be tagged with the [Serializable] attribute.

Once initialized, there are five core methods:

  • Enqueue an object
  • Dequeue an object (note that any dequeued object may be dequeued again if you fail to call the Acknowledge method after using it. It will become invisible to all clients for a default of 30 seconds.)
  • Acknowledge. This means you're done with your processed an dequeued item so it won't become visible to clients again.
  • Extend. After you've dequeued an item, call this method at any time if you need more time to process it before it automatically goes back into the pool.
  • Purge. This removes ALL acknowledged items from persistence and should only be called periodically to clean up the database tables.

Example usage:

using System;
using System.ComponentModel;	
using System.IO;
using System.Threading;
using fissolue.SimpleQueue.EntityFramework;
using fissolue.SimpleQueue.FluentNHibernate;
using FluentNHibernate.Cfg.Db;

public class Program
    private static void Main(string[] args)
	    IPersistenceConfigurer configurer = MsSqlConfiguration.MsSql2012.ConnectionString("Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;");
		//this creates a queue that stores <int> data type, but you could replace it with anything that will serialize. 
		var myQueue = new FluentNHibernateQueue<int>("dummyQueue", configurer, true, new LocalOptions<int> {SerializationType = SerializationTypeEnum.NewtonsoftJson});
		//ok, enqueue some items
		for(var i = 0; i<10; i++){
		//now, de-queue them
		    var dequeuedItem = myQueue.Dequeue();
			if (dequeuedItem == null)
				//queue is empty
			Console.WriteLine(dequeuedItem.Data); //Data property contains the values
			//do more processing here with whatever you pulled out of the queue
			//now let the db know you're done with the item.
		//Clean up

By default, a dequeued item will revert back to enqueued if you don't call the Acknowledge method for it within 30 seconds. To get around this, you can (a) pass a timespan of your choosing as an argument to the Dequeue method, or (b) in the LocalOptions object used to initialize the queue, use the Visibility property to set a default timespan. This mechanism is here essentially so if your process dies, the item stays in the queue.

Sharable on Multiple Clients

Because this is database-backed, you can point multiple processes to it, even if they run on different machines. This implementation intentionally does NOT use database transactions, because we want to avoid deadlock situations.

Code-First Approach

A key feature of SimpleQueue is the fact that you don't even need to bother creating tables in the database. It uses only TWO tables, and you can have as many queues (uniquely named) as you like. In your database of choice, you must have table creation permissions if the SimpleQueue tables don't exist already.

RDMBS Support

Fluent NHibernate supports MS SQL Server with no additional libraries required. For the other databases, your application must include the 'standard' data provider package (from Nuget or otherwise) for the database provider (i.e. MySQL.Data, System.Data.SQLite). Whatever the case, you'll just pass an instance of IPersistenceConfigurer so SimpleQueue knows where to put its data. More info:

Product Versions
.NET Framework net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 834 11/21/2017
1.0.0 595 11/21/2017

Corrected name of main queue object