queue

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2018 License: MIT Imports: 15 Imported by: 0

README

Go client for Azure Service Bus Queue

GoDoc Build status codecov

Install and Use:

Install
$ go get -u github.com/g-rad/go-azurequeue

or if you use dep, within your repo run:

$ dep ensure -add github.com/g-rad/go-azurequeue

If you need to install Go, follow the official instructions.

Use
Init Client

import "github.com/g-rad/go-azurequeue"

cli := queue.QueueClient{
  Namespace:  "my-test",
  KeyName:    "RootManageSharedAccessKey",
  KeyValue:   "ErCWbtgArb55Tqqu9tXgdCtopbZ44pMH01sjpMrYGrE=",
  QueueName:  "my-queue",
  Timeout:    60,
}
Send Message
// create message
msg := queue.NewMessage(]byte("Hello!"))

msg.Properties.Set("Property1", "Value1")
msg.Properties.Set("Property2", "Value2")

// send message
cli.SendMessage(&msg)
Receive Next Message
msg, err := cli.GetMessage()
Unlock Message

If you failed to process a message, unlock it for processing by other receivers.

cli.UnlockMessage(&msg)
Delete Message

This operation completes the processing of a locked message and deletes it from the queue.

cli.DeleteMessage(&msg)

Documentation

Index

Constants

View Source
const Rfc2616Time = "Mon, 02 Jan 2006 15:04:05 MST"

Variables

This section is empty.

Functions

func SetDebugLogger

func SetDebugLogger(log Log)

Sets the package's debug logger. Pass nil to disable debug logging.

func SetErrorLogger

func SetErrorLogger(log Log)

Sets the package's error logger. Pass nil to disable error logging.

func SetHttpClient

func SetHttpClient(client HttpClient)

Sets the package's http client.

Types

type BadRequestError

type BadRequestError struct {
	Code int
	Body string
}

func (BadRequestError) Error

func (e BadRequestError) Error() string

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type InternalError

type InternalError struct {
	Code int
	Body string
}

func (InternalError) Error

func (e InternalError) Error() string

type Log

type Log func(...interface{})

type Message

type Message struct {
	ContentType             string
	CorrelationId           string
	SessionId               string
	DeliveryCount           int
	LockedUntilUtc          time.Time
	LockToken               string
	Id                      string
	Label                   string
	ReplyTo                 string
	EnqueuedTimeUtc         time.Time
	SequenceNumber          int64
	TimeToLive              int
	To                      string
	ScheduledEnqueueTimeUtc time.Time
	ReplyToSessionId        string
	PartitionKey            string

	Properties Properties

	Body []byte
}

Queue Message.

See https://docs.microsoft.com/en-us/rest/api/servicebus/message-headers-and-properties

func NewMessage

func NewMessage(body []byte) *Message

type MessageDontExistError

type MessageDontExistError struct {
	Code int
	Body string
}

func (MessageDontExistError) Error

func (e MessageDontExistError) Error() string

type NoMessagesAvailableError

type NoMessagesAvailableError struct {
	Code int
	Body string
}

func (NoMessagesAvailableError) Error

func (e NoMessagesAvailableError) Error() string

type NotAuthorizedError

type NotAuthorizedError struct {
	Code int
	Body string
}

func (NotAuthorizedError) Error

func (e NotAuthorizedError) Error() string

type Properties

type Properties map[string]string

Properties represents the key-value pairs of message properties.

func (Properties) Get

func (p Properties) Get(key string) string

Get gets the first value associated with the given key. It is case insensitive; textproto.CanonicalMIMEHeaderKey is used to canonicalize the provided key. If there are no values associated with the key, Get returns "".

func (Properties) Set

func (p Properties) Set(key, value string)

Set sets the header entries associated with key to the single element value. It replaces any existing values associated with key.

type QueueClient

type QueueClient struct {
	// Service Bus Namespace e.g. https://<yournamespace>.servicebus.windows.net
	Namespace string

	// Policy name e.g. RootManageSharedAccessKey
	KeyName string

	// Policy value.
	KeyValue string

	// Name of the queue.
	QueueName string

	// Request timeout in seconds.
	Timeout int
	// contains filtered or unexported fields
}

Thread-safe client for Azure Service Bus Queue.

func (*QueueClient) DeleteMessage

func (q *QueueClient) DeleteMessage(msg *Message) error

This operation completes the processing of a locked message and deletes it from the queue or subscription. This operation should only be called after successfully processing a previously locked message, in order to maintain At-Least-Once delivery assurances.

For more information see https://docs.microsoft.com/en-us/rest/api/servicebus/delete-message

func (*QueueClient) SendMessage

func (q *QueueClient) SendMessage(msg *Message) error

Sends message to a Service Bus queue.

func (*QueueClient) UnlockMessage

func (q *QueueClient) UnlockMessage(msg *Message) error

Unlocks a message for processing by other receivers on a specified subscription. This operation deletes the lock object, causing the message to be unlocked. Before the operation is called, a receiver must first lock the message.

For more information see https://docs.microsoft.com/en-us/rest/api/servicebus/unlock-message

type QueueDontExistError

type QueueDontExistError struct {
	Code int
	Body string
}

func (QueueDontExistError) Error

func (e QueueDontExistError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL