myrabbitmq

package module
v0.0.0-...-2827aba Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 3 Imported by: 0

README

myrabbitmq

Use RabbitMQ in golang.

Install RabbitMQ

Fedora: 见 InstallRabbitMQ.md

Install

go get github.com/gtlyy/myrabbitmq

Licence

MIT License - see LICENSE for more details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IfError

func IfError(msg string, err error)

错误处理函数

Types

type RabbitMqClass

type RabbitMqClass struct {
	Conn  *amqp.Connection
	Ch    *amqp.Channel
	Queue amqp.Queue
}

面向对象编程: ==================================================== Start

func (*RabbitMqClass) Bind

func (rabbit *RabbitMqClass) Bind(exchange, exchange_type, routing_key, queue_name string) (err error)

函数:Bind

func (*RabbitMqClass) Close

func (rabbit *RabbitMqClass) Close()

函数:关闭连接和channel

func (*RabbitMqClass) CreateExchange

func (rabbit *RabbitMqClass) CreateExchange(xname, xtype string) (err error)

函数:快速创建 Exchange

func (*RabbitMqClass) CreateQueue

func (rabbit *RabbitMqClass) CreateQueue(queue_name string) error

函数:快速创建Queue

func (*RabbitMqClass) CreateQueueDurable

func (rabbit *RabbitMqClass) CreateQueueDurable(queue_name string, durable bool) error

函数:快速创建Queue。增加 durable (持久化)

func (*RabbitMqClass) CreateQueueReturnName

func (rabbit *RabbitMqClass) CreateQueueReturnName() (string, error)

函数:不指定名字快速创建 Queue ,并返回随机 Queue 名字

func (*RabbitMqClass) Init

func (rabbit *RabbitMqClass) Init(user string, passwd string, url string, port string) (err error)

函数:初始化,包括连接、生成channel

func (*RabbitMqClass) Receive

func (rabbit *RabbitMqClass) Receive(queue_name string, auto_ack bool) (<-chan amqp.Delivery, error)

函数:接收消息,具备参数。。。

func (*RabbitMqClass) ReceiveQueue

func (rabbit *RabbitMqClass) ReceiveQueue() (<-chan amqp.Delivery, error)

函数:接收消息:queue

func (*RabbitMqClass) Send

func (rabbit *RabbitMqClass) Send(exchange, routing_key, msg string) (err error)

函数:发送信息:根据 exchange, routing_key

func (*RabbitMqClass) Setup

func (rabbit *RabbitMqClass) Setup(exchange, exchange_type, routing_key, queue_name string) (err error)

函数:配置 ; 实际上关键是 Bind

Jump to

Keyboard shortcuts

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