AMQP 1.0 client library for Go.
Перейти к файлу
Kale Blankenship a3e580d050 Correctly handle link detach and session end.
It was possible for `Session.mux` to return before an associated link.
Due to an oversight during refactoring the detach logic did not account
for this and the link could deadlock attempting to send the response
Detach.
2018-02-13 19:35:15 -08:00
fuzz Additional type support and encoding/decoding cleanup 2018-01-30 05:59:25 -08:00
internal/testconn Add Sender to Fuzz 2018-01-11 19:51:51 -08:00
.gitattributes Support setting source selector filter (#5) 2018-01-16 07:44:32 -08:00
.gitignore Remove .vscode directory from repo 2018-01-13 16:21:29 -08:00
.travis.yml Replace Go 1.7 with Go 1.8 in Travis config. 2018-01-11 19:51:51 -08:00
CHANGELOG.md Update README and CHANGELOG 2018-01-16 18:34:48 -08:00
LICENSE Initial state machine based implementation 2017-03-30 20:35:53 -07:00
Makefile Don't write TLS key log when running `make integration` 2018-01-11 19:51:51 -08:00
README.md Separate source and target addresses 2018-01-30 07:31:08 -08:00
buffer.go buffer.readFromOnce should not ignore io.EOF 2018-02-11 11:45:22 -08:00
client.go Correctly handle link detach and session end. 2018-02-13 19:35:15 -08:00
conn.go Make TLS connection setup somewhat less convoluted. 2018-02-11 18:49:08 -08:00
decode.go Additional encoding/decoding optimization 2018-02-06 07:48:50 -08:00
doc.go Add doc.go 2017-05-06 18:24:06 -07:00
encode.go Minimized encoded size of arrays of variable length types. 2018-02-11 18:49:08 -08:00
error_pkgerrors.go clean up before alpha release 2017-04-29 16:38:15 -07:00
error_stdlib.go clean up before alpha release 2017-04-29 16:38:15 -07:00
example_test.go Separate source and target addresses 2018-01-30 07:31:08 -08:00
fuzz.go Additional encoding/decoding optimization 2018-02-06 07:48:50 -08:00
fuzz_test.go Additional encoding/decoding optimization 2018-02-06 07:48:50 -08:00
integration_test.go Separate source and target addresses 2018-01-30 07:31:08 -08:00
log.go Print debug statements when built with `-tags debug` 2018-01-11 19:51:51 -08:00
log_debug.go Print debug statements when built with `-tags debug` 2018-01-11 19:51:51 -08:00
marshal_test.go Restrict annotations to string/symbol or int/int64 keys. 2018-02-11 18:49:08 -08:00
sasl.go Additional encoding/decoding optimization 2018-02-06 07:48:50 -08:00
types.go Remove TODOs which are obsolete or that I've decided not to do. 2018-02-11 18:49:08 -08:00

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 project is currently alpha status, though it is currently being used by my employer in a pre-production capacity.

API is subject to change until 1.0.0. If you choose to use this library, please vendor it.

Install

go get -u pack.ag/amqp

Contributing

I'm happy to accept contributions. A proper CONTRIBUTING.md is in the works. In the interim please open an issue before beginning work so we can discuss it. I want to ensure there is no duplication of effort and that any new functionality fits with the goals of the project.

Example Usage

package main

import (
	"context"
	"fmt"
	"log"

	"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.Message{
			Data: []byte("Hello!"),
		})
		if err != nil {
			log.Fatal("Sending message:", err)
		}

		cancel()
		sender.Close()
	}

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

		ctx, cancel := context.WithCancel(ctx)
		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)
		}
	}
}

Notable Bugs/Shortcomings

  • Closing a sessions does not send an end performative.
  • Testing should be improved. Currently fuzz testing and basic Azure Service Bus integration testing is being performed.

Features - Short Term

  • Set sender filters to support Azure Event Hubs. (Supported as of 0.3.0)

Features - Medium Term

  • Support message producer operations. (Supported as of 0.2.0)

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.