Golang library for Azure Service Bus -- https://aka.ms/azsb
Перейти к файлу
Martin Strobel 234d8a44f8 Changing Receive and ReceiveOne to be blocking calls.
Fundamentally, I'm making this change because of advise that @bketelsen gave me. To paraphrase him, "never design your API to have non-blocking calls. It's not the Go way." However, to back that up, it's been something that bit me several times while I was working with this Service Bus library.
2018-09-26 12:18:05 -07:00
atom move atom types into their own package 2018-06-17 13:25:54 -07:00
internal/test Removing hardcoded test attributes 2018-09-12 12:54:15 -07:00
.gitignore Adding Terraform Config 2018-09-13 13:01:39 -07:00
.travis.yml fix badges 2018-06-18 16:28:50 -07:00
Gopkg.lock Removing hardcoded test attributes 2018-09-12 12:54:15 -07:00
Gopkg.toml update deps, fix tests and remove go sdk dep 2018-08-08 11:32:30 -07:00
LICENSE Initial commit 2018-01-10 10:23:46 -08:00
Makefile Adding Terraform Config 2018-09-13 13:01:39 -07:00
README.md Making Examples Executable Tests (#27) 2018-08-07 17:48:41 -07:00
azuredeploy.tf Adding Terraform Config 2018-09-13 13:01:39 -07:00
changelog.md add changelog and update dependencies 2018-07-06 13:54:23 -07:00
handler.go Refactoring type 'Handler' to an interface. 2018-09-25 16:24:23 -07:00
message.go Changing Receive and ReceiveOne to be blocking calls. 2018-09-26 12:18:05 -07:00
message_examples_test.go Changing Receive and ReceiveOne to be blocking calls. 2018-09-26 12:18:05 -07:00
message_test.go added scheduled messages 2018-06-20 16:25:01 -07:00
mgmt.go Removing pointers from helper method signature. 2018-09-18 13:02:42 -07:00
mgmt_test.go add travis integration build and badges 2018-06-18 14:24:08 -07:00
namespace.go Moving Handler definition to message.go 2018-09-21 17:38:39 -07:00
namespace_test.go Removing hardcoded test attributes 2018-09-12 12:54:15 -07:00
package_examples_test.go Changing Receive and ReceiveOne to be blocking calls. 2018-09-26 12:18:05 -07:00
queue.go Changing Receive and ReceiveOne to be blocking calls. 2018-09-26 12:18:05 -07:00
queue_examples_test.go Changing Receive and ReceiveOne to be blocking calls. 2018-09-26 12:18:05 -07:00
queue_manager.go Splitting control and data-plane types into separate files. 2018-09-21 17:21:07 -07:00
queue_test.go Changing Receive and ReceiveOne to be blocking calls. 2018-09-26 12:18:05 -07:00
receiver.go Changing Receive and ReceiveOne to be blocking calls. 2018-09-26 12:18:05 -07:00
sender.go update deps, fix tests and remove go sdk dep 2018-08-08 11:32:30 -07:00
session.go enable opentracing support 2018-05-11 10:27:30 -07:00
subscription.go Changing Receive and ReceiveOne to be blocking calls. 2018-09-26 12:18:05 -07:00
subscription_manager.go Splitting control and data-plane types into separate files. 2018-09-21 17:21:07 -07:00
subscription_test.go Changing Receive and ReceiveOne to be blocking calls. 2018-09-26 12:18:05 -07:00
topic.go Splitting control and data-plane types into separate files. 2018-09-21 17:21:07 -07:00
topic_manager.go Splitting control and data-plane types into separate files. 2018-09-21 17:21:07 -07:00
topic_test.go Removing context from Subscription and Topic constructors. (#37) 2018-08-25 12:29:30 -07:00
tracing.go Adding a nil check to applyResponseInfo 2018-07-25 14:43:10 -07:00

README.md

Microsoft Azure Service Bus Client for Golang

Go Report Card godoc Build Status Coverage Status

Microsoft Azure Service Bus is a reliable cloud messaging service (MaaS) which simplifies enterprise cloud messaging. It enables developers to build scalable cloud solutions and implement complex messaging workflows over an efficient binary protocol called AMQP.

This library provides a simple interface for sending, receiving and managing Service Bus entities such as Queues, Topics and Subscriptions.

For more information about Service Bus, check out the Azure documentation.

This library is a pure Golang implementation of Azure Service Bus over AMQP.

Preview of Service Bus for Golang

This library is currently a preview. There may be breaking interface changes until it reaches semantic version v1.0.0. If you run into an issue, please don't hesitate to log a new issue or open a pull request.

Installing the library

To more reliably manage dependencies in your application we recommend golang/dep.

With dep:

dep ensure -add github.com/Azure/azure-service-bus-go

With go get:

go get -u github.com/Azure/azure-service-bus-go/...

If you need to install Go, follow the official instructions

Using Service Bus

In this section we'll cover some basics of the library to help you get started.

Quick start

Let's send and receive "hello, world!".

package main

import (
	"context"
	"fmt"
	"os"
	"os/signal"

	"github.com/Azure/azure-service-bus-go"
)

func main() {
	connStr := os.Getenv("SERVICEBUS_CONNECTION_STRING")
	ns, err := servicebus.NewNamespace(servicebus.NamespaceWithConnectionString(connStr))
	if err != nil {
		// handle error
	}

	// Initialize and create a Service Bus Queue named helloworld if it doesn't exist
	queueName := "helloworld"
	q, err := ns.NewQueue(queueName)
	if err != nil {
		// handle queue creation error
	}

	// Send message to the Queue named helloworld
	err = q.Send(context.Background(), servicebus.NewMessageFromString("Hello World!"))
	if err != nil {
		// handle message send error
	}

	// Receive message from queue named helloworld
	listenHandle, err := q.Receive(context.Background(),
		func(ctx context.Context, msg *servicebus.Message) servicebus.DispositionAction {
			fmt.Println(string(msg.Data))
			return msg.Accept()
		})
	if err != nil {
		// handle queue listener creation err
	}
	// Close the listener handle for the Service Bus Queue
	defer listenHandle.Close(context.Background())

	// Wait for a signal to quit:
	signalChan := make(chan os.Signal, 1)
	signal.Notify(signalChan, os.Interrupt, os.Kill)
	<-signalChan
}

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.