Skip to content

当使用ali_mns.MessageSendRequest{} Priority 缺省值时再使用SendMessage() 函数向队发送消息时,报有关 Priority 值错误 #12

@penghuima

Description

@penghuima

上下文

当我调用sdk 给阿里云 mns 队列发送消息时

//发送一条消息
	msg := ali_mns.MessageSendRequest{
		MessageBody: "hello error <\"aliyun-mns-go-sdk\">",
  }
	ret, err := queue.SendMessage(msg)

结果报错内容如下:

ali_mns response status error,code: InvalidArgument, message: The value of Priority should between 1 and 16, 

很显然如果给队列发送消息的时候,如果我使用缺省值,那么就会使 Priority=0,显然与官网 SendMessage api 中规定的 Priority 取值范围:1~16,数值越小优先级越高,默认值:8 。相冲突导致了错误。

建议:

在原始以下代码函数中应该加一个Priority判断,如果监测到用户没有设置该值,则将 Priority 值设为官方默认值 8

func (p *aliMNSClient) Send(method Method, headers map[string]string, message interface{}, resource string) (*fasthttp.Response, error) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions