Skip to content
This repository was archived by the owner on Jun 7, 2026. It is now read-only.

Latest commit

 

History

History
40 lines (35 loc) · 1.1 KB

File metadata and controls

40 lines (35 loc) · 1.1 KB

Red Capped

A lightweight .NET message queue system with QoS support, built on top of MongoDb.

Build status

Define the message payload

public class Order
{
  public int Id { get; set; }
  public decimal Amount { get; set; }
  ...
}

How to publish messages

// create the queues manager
var factory = new QueueFactory("mongodb://localhost", "mydb");
// create the queue
var queue = await factory.CreateQueue<Order>(queueName, 256*1024*1024);
// publish!
await queue.PublishAsync(new Order { Id = 123, Amount = 120M });

How to subscribe and receive messages

// create the queues manager
var factory = new QueueFactory("mongodb://localhost", "mydb");
// create the queue
var queue = await factory.CreateQueue<Order>(queueName, 256*1024*1024);
// subscribe
queue.Subscribe(order =>
{
  Debug.WriteLine("Order #{0} amount {1}", order.Id, order.Amount);
  // return true if the message was handled, otherwise it will be requeued
  return true;
});