mirror of
https://github.com/fhmq/hmq.git
synced 2026-08-29 14:03:10 +00:00
allow bridge mq cost msg (#162)
This commit is contained in:
+4
-2
@@ -5,11 +5,13 @@ import (
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (b *Broker) Publish(e *bridge.Elements) {
|
||||
func (b *Broker) Publish(e *bridge.Elements) bool {
|
||||
if b.bridgeMQ != nil {
|
||||
err := b.bridgeMQ.Publish(e)
|
||||
cost, err := b.bridgeMQ.Publish(e)
|
||||
if err != nil {
|
||||
log.Error("send message to mq error.", zap.Error(err))
|
||||
}
|
||||
return cost
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
+5
-1
@@ -414,7 +414,7 @@ func (c *client) processClientPublish(packet *packets.PublishPacket) {
|
||||
}
|
||||
|
||||
//publish to bridge mq
|
||||
c.broker.Publish(&bridge.Elements{
|
||||
cost := c.broker.Publish(&bridge.Elements{
|
||||
ClientID: c.info.clientID,
|
||||
Username: c.info.username,
|
||||
Action: bridge.Publish,
|
||||
@@ -423,6 +423,10 @@ func (c *client) processClientPublish(packet *packets.PublishPacket) {
|
||||
Topic: topic,
|
||||
})
|
||||
|
||||
if cost {
|
||||
return
|
||||
}
|
||||
|
||||
switch packet.Qos {
|
||||
case QosAtMostOnce:
|
||||
c.ProcessPublishMessage(packet)
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ func (c *client) SendInfo() {
|
||||
}
|
||||
url := c.info.localIP + ":" + c.broker.config.Cluster.Port
|
||||
|
||||
infoMsg := NewInfo(c.broker.id, url, false)
|
||||
infoMsg := NewInfo(c.broker.id, url)
|
||||
err := c.WriterPacket(infoMsg)
|
||||
if err != nil {
|
||||
log.Error("send info message error, ", zap.Error(err))
|
||||
@@ -60,7 +60,7 @@ func (c *client) SendConnect() {
|
||||
log.Info("send connect success")
|
||||
}
|
||||
|
||||
func NewInfo(sid, url string, isforword bool) *packets.PublishPacket {
|
||||
func NewInfo(sid, url string) *packets.PublishPacket {
|
||||
pub := packets.NewControlPacket(packets.Publish).(*packets.PublishPacket)
|
||||
pub.Qos = 0
|
||||
pub.TopicName = BrokerInfoTopic
|
||||
|
||||
Reference in New Issue
Block a user