rabbitmq

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

README

RabbitMQ

创建连接

rabbit, _ := NewRabbit("127.0.0.1:5672", "/", "user", "pwd")

发送消息

//send to mq
rabbit.SendToQue("exchange", "key", []byte("OK"))

接收消息

//receive from mq
msgs, _ := rabbit.ReceiveFromMQ("exchange", "key", "queue", nil)
for msg := range msgs {
    log.Println("Receive a message from mq: ", string(msg.Body))

    //do some thing

}

限流

每次ack后,再接收新消息
rabbit.SetQos(1,0,true)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rabbit

type Rabbit struct {
	// contains filtered or unexported fields
}

Rabbit

func NewRabbit

func NewRabbit(server, vhost, userName, password string) (*Rabbit, error)

NewRabbit

func (*Rabbit) GetQueue

func (mq *Rabbit) GetQueue(name string, args amqp.Table) (queue amqp.Queue, err error)

GetQueue assume the queue is already exist

func (*Rabbit) ReceiveFromMQ

func (mq *Rabbit) ReceiveFromMQ(exchange, key, queue string, args amqp.Table) (msgs <-chan amqp.Delivery, err error)

ReceiveFromMQ

func (*Rabbit) Reconnect

func (mq *Rabbit) Reconnect() (err error)

Reconnect

func (*Rabbit) SendToDLQue

func (mq *Rabbit) SendToDLQue(exchange, key, queue string, body []byte, args amqp.Table) (err error)

func (*Rabbit) SendToQue

func (mq *Rabbit) SendToQue(exchange, key string, body []byte) (err error)

func (*Rabbit) SetQos

func (mq *Rabbit) SetQos(count, size int, global bool) (err error)

SetQos

Jump to

Keyboard shortcuts

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