Available

amalgame-rabbitmq

RabbitMQ / AMQP 0.9.1 via librabbitmq.

amc package add rabbitmq GitHub ↗ ← Back to the ecosystem

Overview

AMQP 0.9.1 client linked to librabbitmq (rabbitmq-c), which must be installed on the machine. It works with RabbitMQ and other AMQP 0.9.1 brokers reachable without TLS.

Features

  • ✓Exchanges (direct, fanout, topic, headers)
  • ✓Auto-delete, non-durable queues; server-chosen name if you pass an empty string
  • ✓Publish, Consume, Poll and Ack
  • ✓Needs librabbitmq-dev to build, librabbitmq4 to run (Debian, Ubuntu)

Planned for v2: TLS, durable queues and persistent messages, several channels, publisher confirms.

Example

Minimal usage example — copy-paste runnable after install.

amc package add rabbitmq

import Amalgame.Messaging.RabbitMQ

public class Program {
    public static void Main(string[] args) {
        let r = RabbitMQ.Connect("localhost", 5672, "guest", "guest", "/")
        if (!RabbitMQ.IsOpen(r)) {
            Console.WriteLine("connect failed: " + RabbitMQ.LastError(r))
            return
        }
        RabbitMQ.DeclareExchange(r, "events", "topic")
        let q: string = RabbitMQ.DeclareQueue(r, "")
        RabbitMQ.Bind(r, q, "events", "user.*")
        RabbitMQ.Publish(r, "events", "user.login", "id=42")
        RabbitMQ.Consume(r, q)
        while (RabbitMQ.Poll(r, 2000)) {
            Console.WriteLine(RabbitMQ.LastRoutingKey(r) + " = " + RabbitMQ.LastBody(r))
            RabbitMQ.Ack(r)
        }
        RabbitMQ.Close(r)
    }
}

At a glance

Related packages