mq

package
v0.0.0-...-3d0adf2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : mq.go # Created : 2019/1/8 19:20 # Last Modified : 2019/1/8 19:20 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : receiver.go # Created : 2019/1/8 19:20 # Last Modified : 2019/1/8 19:20 # Describe : # # ====================================================

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RabbitConn

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

func New

func New(addr string) (*RabbitConn, error)

New 按地址新建连接到mq

func (*RabbitConn) Close

func (c *RabbitConn) Close() error

Close 关闭连接

func (*RabbitConn) Connection

func (c *RabbitConn) Connection() *amqp.Connection

func (*RabbitConn) RabbitMQ

func (c *RabbitConn) RabbitMQ(exName, exType string, exArgs amqp.Table) (*RabbitMQ, error)

New 初始化实例

type RabbitMQ

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

func (*RabbitMQ) Close

func (r *RabbitMQ) Close() (err error)

Close 关闭conn和channel

func (*RabbitMQ) Publish

func (r *RabbitMQ) Publish(ctx context.Context, routeKey string, publishing amqp.Publishing) error

func (*RabbitMQ) ReConnect

func (r *RabbitMQ) ReConnect(conn *amqp.Connection) error

ReConnect 重新连接channel

func (*RabbitMQ) RegisterReceiver

func (r *RabbitMQ) RegisterReceiver(receiver Receiver)

RegisterReceiver 注册一个用于接收指定队列指定路由的数据接收者

func (*RabbitMQ) Start

func (r *RabbitMQ) Start(conn *amqp.Connection)

Start 启动消费者

type Receiver

type Receiver interface {
	QueueName() string     // 获取接收者需要监听的队列
	RouterKey() string     // 这个队列绑定的路由
	OnError(error)         // 处理遇到的错误,当RabbitMQ对象发生了错误,他需要告诉接收者处理错误
	OnReceive([]byte) bool // 处理收到的消息, 这里需要告知RabbitMQ对象消息是否处理成功
}

Jump to

Keyboard shortcuts

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