Skip to content
AMQP 1.0 client library for Go.
Branch: master
Clone or download
vcabbage Return server link creation error at time of Sender/Receiver creation.
Server errors during link creation are reported by sending an Attach
without a source or target and immediately sending a follow up Detach.
Check for this situation and wait for the Detach so the error can be
returned to the user immediately.
Latest commit ca53772 Jun 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
fuzz Additional type support and encoding/decoding cleanup Jan 30, 2018
internal/testconn Fix linting warnings/errors Feb 17, 2018
.gitattributes Support setting source selector filter (#5) Jan 16, 2018
.gitignore Remove .vscode directory from repo Jan 14, 2018
.travis.yml Prevent out of bounds due to overflows on 32-bit platforms Jun 22, 2018
CONTRIBUTING.md Update README.md and add CONTRIBUTING.md Jan 10, 2019
LICENSE Initial state machine based implementation Mar 31, 2017
Makefile Fix compile error on 386 and run unit tests with GOARCH=386 in CI Jun 22, 2018
README.md Add a Related Projects section to README Feb 25, 2019
bitmap.go Reuse handle and channel numbers Apr 15, 2018
bitmap_test.go Reuse handle and channel numbers Apr 15, 2018
buffer.go Prevent out of bounds due to overflows on 32-bit platforms Jun 22, 2018
client.go Return server link creation error at time of Sender/Receiver creation. Jun 19, 2019
client_test.go Export LinkSourceFilter and remove LinkSessionFilter. Oct 23, 2018
conn.go Handle server initiated connection close. Jan 30, 2019
conn_test.go Add tests for ConnOptions and LinkOptions Feb 17, 2018
decode.go Fix null type handling in readAny (#117) Aug 1, 2018
doc.go Add doc.go May 7, 2017
encode.go Fix null type handling in readAny (#117) Aug 1, 2018
error_pkgerrors.go clean up before alpha release Apr 29, 2017
error_stdlib.go clean up before alpha release Apr 29, 2017
example_test.go Add support for graceful close timeouts via contect.Context Apr 11, 2018
fuzz.go Add support for graceful close timeouts via contect.Context Apr 11, 2018
fuzz_test.go Additional encoding/decoding optimization Feb 6, 2018
helpers_test.go Add tests for ConnOptions and LinkOptions Feb 17, 2018
integration_test.go Return server link creation error at time of Sender/Receiver creation. Jun 19, 2019
log.go Print debug statements when built with `-tags debug` Jan 12, 2018
log_debug.go Wait for response disposition when Receiver w/ rcv-settle-mode second. Jun 18, 2018
marshal_test.go Add LinkSourceDurability and LinkSourceExpiryPolicy options. Oct 23, 2018
sasl.go Additional encoding/decoding optimization Feb 6, 2018
types.go Fix settlement mode negotiation. Feb 28, 2019

README.md

pack.ag/amqp

Go Report Card Coverage Status Build Status Build status GoDoc MIT licensed

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

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"
)

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)
	}

	ctx := context.Background()

	// Send a message
	{
		// Create a sender
		sender, err := session.NewSender(
			amqp.LinkTargetAddress("/queue-name"),
		)
		if err != nil {
			log.Fatal("Creating sender link:", err)
		}

		ctx, cancel := context.WithTimeout(ctx, 5*time.Second)

		// Send message
		err = sender.Send(ctx, amqp.NewMessage([]byte("Hello!")))
		if err != nil {
			log.Fatal("Sending message:", err)
		}

		sender.Close(ctx)
		cancel()
	}

	// Continuously read messages
	{
		// Create a receiver
		receiver, err := session.NewReceiver(
			amqp.LinkSourceAddress("/queue-name"),
			amqp.LinkCredit(10),
		)
		if err != nil {
			log.Fatal("Creating receiver link:", err)
		}
		defer func() {
			ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
			receiver.Close(ctx)
			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.GetData())
		}
	}
}

Related Projects

Project Description
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-proton AMQP 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.

You can’t perform that action at this time.