rabbitmq操作
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.1 KiB

package rabbitmq
import (
"encoding/json"
)
/**
* 发送一条api通知消息
* @param exchange 交换机名
* @param extype 消息类型
* @param route 路由key
* @param body 内容
*/
func SendNotice(site_id, dbname, msg_id string) error {
msgData := map[string]interface{}{
"site_id": site_id,
"dbname": dbname,
"data": map[string]string{
"msg_id": msg_id,
},
}
msgDataJson, err := json.Marshal(msgData)
if err != nil {
return err
}
return Send("direct", SEND_MSG_EXCHANGE, SEND_API_MSG_KEY, msgDataJson)
}
/**
* 发布订单已支付消息
* @param exchange 交换机名
* @param extype 消息类型
* @param route 路由key
* @param body 内容
*/
func SendOrderPayed(site_id, dbname, order_id, order_sn, price string) error {
//发布订单已支付消息
orderData := map[string]interface{}{
"site_id": site_id,
"dbname": dbname,
"data": map[string]string{
"order_id": order_id,
"order_sn": order_sn,
"price": price,
},
}
orderDataJson, _ := json.Marshal(orderData)
return Send("direct", ORDER_EXCHANGE, ORDER_PAYED_KEY, orderDataJson)
}