mq

package
v0.0.0-...-8b2440d Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RabbitMQ

type RabbitMQ struct {
	Uri     string //amqp://guest:guest@localhost:5672/
	Conn    *amqp.Connection
	Channel *amqp.Channel
}

func NewRabbitMQ

func NewRabbitMQ(uri string, config amqp.Config) (*RabbitMQ, error)

return a rabbitMQ object

func (*RabbitMQ) BindQueueToExchange

func (rq *RabbitMQ) BindQueueToExchange(consumerKey string, messageName string, routeKey string) error

bind queue to exchange params: consumerKey : message name+"-"consumerID messageName : message name routeKey : consumer routeKey

func (*RabbitMQ) Close

func (rq *RabbitMQ) Close()

close conn

func (*RabbitMQ) Consume

func (rq *RabbitMQ) Consume(queue string, consumer string) (<-chan amqp.Delivery, error)

consume

func (*RabbitMQ) DeclareConsumer

func (rq *RabbitMQ) DeclareConsumer(consumerKey string, durable bool, messageName string, consumerRouteKey string) (err error)

declare consumer

func (*RabbitMQ) DeclareExchange

func (rq *RabbitMQ) DeclareExchange(name string, kind string, durable bool) error

declare exchange params: name : exchange name kind : exchange type (fanout, topic, direct) durable: true or false save exchange when the server is restarted

func (*RabbitMQ) DeclareQueue

func (rq *RabbitMQ) DeclareQueue(name string, durable bool) (queue amqp.Queue, err error)

declare queue params: name : queue name durable : durable

func (*RabbitMQ) DeleteExchange

func (rq *RabbitMQ) DeleteExchange(name string) error

delete a exchange params: name : exchange name

func (*RabbitMQ) DeleteQueue

func (rq *RabbitMQ) DeleteQueue(name string) error

delete queue params: name : queue name

func (*RabbitMQ) GetChannel

func (rq *RabbitMQ) GetChannel() (*amqp.Channel, error)

get mq Channel

func (*RabbitMQ) GetConnect

func (rq *RabbitMQ) GetConnect() *amqp.Connection

get mq connect

func (*RabbitMQ) GetExchangeName

func (rq *RabbitMQ) GetExchangeName(name string) string

get real exchange name(prefix+exchange)

func (*RabbitMQ) Publish

func (rq *RabbitMQ) Publish(exchange string, routeKey string, body string) error

publish message params: exchange : message name routeKey : route_key body : publish body

func (*RabbitMQ) UnBindQueueToExchange

func (rq *RabbitMQ) UnBindQueueToExchange(consumerKey string, messageName string, routeKey string) error

unbind queue to exchange params: consumerKey : message name+"-"consumerID messageName : message name routeKey : consumer routeKey

Jump to

Keyboard shortcuts

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