https://github.com/jkone27/alicemq
A reactive client library for RabbitMQ and Google PubSub, with observables, acknowledge and reject capabilities
https://github.com/jkone27/alicemq
alice consumer google-pubsub messaging messaging-library queue rabbitmq rabbitmq-client
Last synced: about 1 year ago
JSON representation
A reactive client library for RabbitMQ and Google PubSub, with observables, acknowledge and reject capabilities
- Host: GitHub
- URL: https://github.com/jkone27/alicemq
- Owner: jkone27
- License: mit
- Created: 2016-01-13T16:39:39.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-03-14T09:22:54.000Z (over 2 years ago)
- Last Synced: 2025-06-07T05:47:39.118Z (about 1 year ago)
- Topics: alice, consumer, google-pubsub, messaging, messaging-library, queue, rabbitmq, rabbitmq-client
- Language: C#
- Homepage:
- Size: 625 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://techforpalestine.org/learn-more)
[](https://stand-with-ukraine.pp.ua)
# AliceMQ [](https://www.nuget.org/packages/AliceMQ)

A reactive client library with support for RabbitMq and experimental support for google pubsub (TBR),
using reactive extensions for .net
## local environment setup
for rabbitmq:
```docker
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
```
or for the google pubsub version you can run an emulator like
```docker
docker run --rm -ti -p 8681:8681 -e PUBSUB_PROJECT1=test-proj,topic1:subscription1 messagebird/gcloud-pubsub-emulator:latest
```
[](https://github.com/jkone27/AliceMQ/issues)
## Mailman (Producer)
Usage of a mailman is dead simple:
```cs
using AliceMQ.Core.Message;
using AliceMQ.Core.Types;
using AliceMQ.Rabbit.MailBox;
using AliceMQ.Rabbit.Mailman;
//for for g pubsub version: using AliceMQ.PubSub;
//parameters are slightly different..
var source = new Source("A", "A.q");
var endPoint = new EndPoint();
var sink = new Sink(source);
var serialization = new JsonSerializerSettings
{
MissingMemberHandling = MissingMemberHandling.Error
};
var p = new Mailman(endPoint, source.Exchange, s => JsonConvert.SerializeObject(s, serialization));
//first message published creates exchange if non existent
p.PublishOne(new Msg(-1),"");
```
Now let's see the simplest form of consumer, which is just a thin layer from the real MQ system...
## SimpleMailbox (Consumer of BasicDeliverEventArgs)
Consumer subscription is identical for every type, giving an istance of an IObservable (rx).
```cs
using AliceMQ.Mailbox;
var mb = new SimpleMailbox(endPoint, sink);
using var d = mb.Subscribe(am =>
{
Console.WriteLine("A - " + Encoding.UTF8.GetString(am.EventArgs.Body));
am.Channel.BasicAck(am.EventArgs.DeliveryTag, false);
});
```
## Mailbox\ (Consumer of T)
let's consider an example DTO class Msg, the typed consumer is build upon the common consumer, which is enhanced with message body deserialization into an istance of a generic T type.
```cs
var sfm = new Mailbox(endPoint, sink, s => JsonConvert.DeserializeObject(s, serialization));
using var d = sfm.Subscribe(am =>
{
if (am.IsOk())
{
var msg = am.AsOk().Message;
Console.WriteLine("ok - " + msg.Bla);
am.Confirm();
}
else
{
Console.WriteLine("error - " + am.AsError().Ex.Message);
am.Reject();
}
},
ex => Console.WriteLine("COMPLETE ERROR"),
() => Console.WriteLine("COMPLETE"));
```
### Status
[](https://travis-ci.org/jkone27/AliceMQ)