From 4bcdddaf15968c0ad64fd04d417984eb3e1838f1 Mon Sep 17 00:00:00 2001 From: Meng Yan Date: Wed, 13 Sep 2023 04:21:18 +0000 Subject: [PATCH] move it to write message Signed-off-by: Meng Yan --- protocol/mqtt_paho/v2/protocol.go | 1 - protocol/mqtt_paho/v2/write_message.go | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/protocol/mqtt_paho/v2/protocol.go b/protocol/mqtt_paho/v2/protocol.go index 0be53c8b..261fc6c3 100644 --- a/protocol/mqtt_paho/v2/protocol.go +++ b/protocol/mqtt_paho/v2/protocol.go @@ -90,7 +90,6 @@ func (p *Protocol) Send(ctx context.Context, m binding.Message, transformers ... defer m.Finish(err) msg := p.publishOption - msg.Properties.User = make(paho.UserProperties, 0) if cecontext.TopicFrom(ctx) != "" { msg.Topic = cecontext.TopicFrom(ctx) cecontext.WithTopic(ctx, "") diff --git a/protocol/mqtt_paho/v2/write_message.go b/protocol/mqtt_paho/v2/write_message.go index 7c925502..a4b87f4a 100644 --- a/protocol/mqtt_paho/v2/write_message.go +++ b/protocol/mqtt_paho/v2/write_message.go @@ -58,10 +58,10 @@ func (b *pubMessageWriter) SetStructuredEvent(ctx context.Context, f format.Form func (b *pubMessageWriter) Start(ctx context.Context) error { if b.Properties == nil { - b.Properties = &paho.PublishProperties{ - User: make([]paho.UserProperty, 0), - } + b.Properties = &paho.PublishProperties{} } + // the UserProperties of publish message is used to load event extensions + b.Properties.User = make([]paho.UserProperty, 0) return nil }