Skip to content
This repository was archived by the owner on Dec 14, 2020. It is now read-only.

Latest commit

History

216 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

pack.ag/amqp

Go Report CardCoverage StatusBuild StatusGoDocMIT licensed

pack.ag/amqp is an AMQP 1.0 client implementation for Go.

NOTE: This project is no longer under active development. See issue #205 for details.

AMQP 1.0 is not compatible with AMQP 0-9-1 or 0-10, which are the most common AMQP protocols in use today. A list of AMQP 1.0 brokers and other AMQP 1.0 resources can be found at github.com/xinchen10/awesome-amqp.

This library aims to be stable and worthy of production usage, but the API is still subject to change. To conform with SemVer, the major version will remain 0 until the API is deemed stable. During this period breaking changes will be indicated by bumping the minor version. Non-breaking changes will bump the patch version.

Install

go get -u pack.ag/amqp

Contributing

Contributions are welcome! Please see CONTRIBUTING.md.

Example Usage

package main
import (
"context""fmt""log""time""pack.ag/amqp"
)
funcmain() {
// Create clientclient, err:=amqp.Dial("amqps://my-namespace.servicebus.windows.net",
amqp.ConnSASLPlain("access-key-name", "access-key"),
)
iferr!=nil {
log.Fatal("Dialing AMQP server:", err)
}
deferclient.Close()
// Open a sessionsession, err:=client.NewSession()
iferr!=nil {
log.Fatal("Creating AMQP session:", err)
}
ctx:=context.Background()
// Send a message
{
// Create a sendersender, err:=session.NewSender(
amqp.LinkTargetAddress("/queue-name"),
)
iferr!=nil {
log.Fatal("Creating sender link:", err)
}
ctx, cancel:=context.WithTimeout(ctx, 5*time.Second)
// Send messageerr=sender.Send(ctx, amqp.NewMessage([]byte("Hello!")))
iferr!=nil {
log.Fatal("Sending message:", err)
}
sender.Close(ctx)
cancel()
}
// Continuously read messages
{
// Create a receiverreceiver, err:=session.NewReceiver(
amqp.LinkSourceAddress("/queue-name"),
amqp.LinkCredit(10),
)
iferr!=nil {
log.Fatal("Creating receiver link:", err)
}
deferfunc() {
ctx, cancel:=context.WithTimeout(ctx, 1*time.Second)
receiver.Close(ctx)
cancel()
}()
for {
// Receive next messagemsg, err:=receiver.Receive(ctx)
iferr!=nil {
log.Fatal("Reading message from AMQP:", err)
}
// Accept messagemsg.Accept()
fmt.Printf("Message received: %s\n", msg.GetData())
}
}
}

Related Projects

ProjectDescription
github.com/Azure/azure-event-hubs-go *Library for interacting with Microsoft Azure Event Hubs.
github.com/Azure/azure-service-bus-go *Library for interacting with Microsoft Azure Service Bus.
gocloud.dev/pubsub *Library for portably interacting with Pub/Sub systems.
qpid-protonAMQP 1.0 library using the Qpid Proton C bindings.

* indicates that the project uses this library.

Feel free to send PRs adding additional projects. Listed projects are not limited to those that use this library as long as they are potentially useful to people who are looking at an AMQP library.

Other Notes

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.

About

AMQP 1.0 client library for Go.

Topics

Resources

Contributing

Stars

135 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages