rocketmq5Kit

package
v3.0.37 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultAwaitDuration (Consumer)maximum waiting time for receive func
	DefaultAwaitDuration = time.Second * 5

	// DefaultMaxMessageNum (Consumer)maximum number of messages received at one time
	DefaultMaxMessageNum int32 = 64

	// DefaultInvisibleDuration (Consumer)should > 20s
	DefaultInvisibleDuration = time.Second * 20
)

Variables

View Source
var (
	NotSetupError = errorKit.Newf("haven’t been set up correctly")
)

Functions

func GetTagString

func GetTagString(tag *string) string

func MixTags

func MixTags(tags ...string) string

func MustSetUp

func MustSetUp(c *Config, clientLogPath string, verifyConfig *VerifyConfig)

func NewMessage

func NewMessage(topic string, body []byte, tag *string) *rmq_client.Message

NewMessage

@param tag 可以为nil @return Producer发送的消息

func NewProducer

func NewProducer() (rmq_client.Producer, error)

NewProducer

PS: (1) In most case, you don't need to create many producers, singletion pattern is more recommended. (2) 需要先 set up!!! (3) 第一个返回值,非nil的情况下,不再需要时请调用 GracefulStop().

@param clientLogPath 客户端日志(blank则输出到控制台)

func NewSimpleConsumer

func NewSimpleConsumer(consumerGroup string, subscriptionExpressions map[string]*rmq_client.FilterExpression) (rmq_client.SimpleConsumer, error)

NewSimpleConsumer

PS: (1) In most case, you don't need to create many consumers, singletion pattern is more recommended. (2) 需要先 set up!!! (3) 第一个返回值,非nil的情况下,不再需要时请调用 GracefulStop().

@param consumerGroup 不能为"" @param subscriptionExpressions (1) key: topic,不能为 "*" || blank

(2) value: 	tag,一般为 rmq_client.SUB_ALL

@param clientLogPath 客户端日志(blank则输出到控制台)

func SendMessage

func SendMessage(producer rmq_client.Producer, ctx context.Context, topic string, tag *string, body []byte, messageGroup string, deliveryTimestamp time.Time, keys ...string) ([]*rmq_client.SendReceipt, error)

SendMessage Deprecated: 仅供参考如何生产消息

func SetUp

func SetUp(c *Config, clientLogPath string, verifyConfig *VerifyConfig) (err error)

SetUp

@param clientLogPath 可以为""(输出到控制台) @param verifyConfig 可以为nil(不进行验证)

Types

type Config

type Config struct {
	Endpoints   []string                        `json:"endpoints" yaml:"endpoints" validate:"required,unique,dive,hostname_port"`
	Credentials *credentials.SessionCredentials `json:"credentials" yaml:"credentials"`
}

type VerifyConfig

type VerifyConfig struct {
	// Topic 用于验证的topic(理论上,此topic仅用于测试,不能同时用于业务,因为测试发的消息无意义).
	/*
		PS: 为空则不进行验证.
	*/
	Topic string

	// LogPath 用于测试的日志文件路径(如果为空,则输出到控制台).
	LogPath string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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