github.com/gpolek/amqp is an AMQP 1.0 client implementation for Go.
Forked from pack.ag/amqp
AMQP 1.0 is not compatible with AMQP 0-9-1 or 0-10, which are the most common AMQP protocols in use today.
This project is currently alpha status, though is currently being used by my employer in a pre-production capacity. The current focus is reading from Microsoft Azure's Service Bus. Only receive operations have been implemented. Producer operations will be implemented later.
API is subject to change until 1.0.0. If you choose to use this library, please vendor it.
go get -u github.com/gpolek/amqp
package mypackage
import (
"context"
"fmt"
"log"
"github.com/gpolek/amqp"
)
func main() {
// Create client
client, err := amqp.Dial("amqps://my-namespace.servicebus.windows.net",
amqp.ConnSASLPlain("access-key-name", "access-key"),
)
if err != nil {
log.Fatal("Dialing AMQP server:", err)
}
defer client.Close()
// Open a session
session, err := client.NewSession()
if err != nil {
log.Fatal("Creating AMQP session:", err)
}
// Create a receiver
receiver, err := session.NewReceiver(
amqp.LinkSource("/queue-name"),
amqp.LinkCredit(10),
)
if err != nil {
log.Fatal("Creating receiver link:", err)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
for {
// Receive next message
msg, err := receiver.Receive(ctx)
if err != nil {
log.Fatal("Reading message from AMQP:", err)
}
// Accept message
msg.Accept()
fmt.Printf("Message received: %s\n", msg.Data)
}
}
- Closing a sessions does not send an end performative.
- Testing is lacking. Only fuzz testing is currently being performed.
- Set sender filters to support Azure Event Hubs.
- Support message producer operations.
By default, this package depends only on the standard library. Building with the
pkgerrors
tag will cause errors to be created/wrapped by the github.com/pkg/errors
library. This can be useful for debugging and when used in a project using
github.com/pkg/errors.