SpringMessage

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: Apache-2.0 Imports: 5 Imported by: 1

README

spring-message

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BindConsumer

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

BindConsumer BIND 方式实现的消费者

func BIND

func BIND(topic string, fn interface{}) *BindConsumer

BIND 创建 BIND 方式实现的消费者

func (*BindConsumer) Consume

func (c *BindConsumer) Consume(ctx context.Context, msg *Message)

func (*BindConsumer) Topics

func (c *BindConsumer) Topics() []string

type Consumer

type Consumer interface {
	Topics() []string // 声明消费的主题列表
	Consume(ctx context.Context, msg *Message)
}

Consumer 消息消费者

type Message

type Message struct {
	Topic      string
	Body       []byte            // 也叫 Value
	MessageId  string            // 也叫 Key
	Properties map[string]string // 附加的属性对
}

Message 简单消息

func NewMessage

func NewMessage() *Message

NewMessage Message 的构造函数

func (*Message) AddProperty

func (msg *Message) AddProperty(key, value string) *Message

AddProperty 给 Message 添加一个属性对

func (*Message) WithBody

func (msg *Message) WithBody(body []byte) *Message

WithBody 设置 Message 的消息体

func (*Message) WithJsonBody

func (msg *Message) WithJsonBody(body interface{}) *Message

WithJsonBody 设置 Message 的消息体 NOTE:到底应不应该抛可愁死我了!

func (*Message) WithMessageId

func (msg *Message) WithMessageId(msgId string) *Message

WithMessageId 设置 Message 的消息 ID

func (*Message) WithTopic

func (msg *Message) WithTopic(topic string) *Message

WithTopic 设置 Message 的 Topic

type MessageInterface

type MessageInterface interface{}

MessageInterface 抽象化的消息接口

type Producer

type Producer interface {
	// SendMessage 发送消息,msg 类型不同用途也不同,需要实现方自行判断
	SendMessage(ctx context.Context, msg MessageInterface) error
}

Producer 消息生产者

Jump to

Keyboard shortcuts

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