From e5bc943594f0fd3bbbb0cef90410985708bcc24a Mon Sep 17 00:00:00 2001 From: Chris Pahl Date: Mon, 8 Jun 2020 11:14:45 +0200 Subject: [PATCH 1/3] remove superfluous func closure --- router.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/router.go b/router.go index 1ce0c402..947b7b70 100644 --- a/router.go +++ b/router.go @@ -168,10 +168,8 @@ func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order } r.RUnlock() for _, handler := range handlers { - func() { - handler(client, m) - m.Ack() - }() + handler(client, m) + m.Ack() } // DEBUG.Println(ROU, "matchAndDispatch handled message") } From a95cb6a4e65807e28208a0aabda6a9899cc463be Mon Sep 17 00:00:00 2001 From: Chris Pahl Date: Mon, 8 Jun 2020 11:14:57 +0200 Subject: [PATCH 2/3] leave note about blocking behavior in Subscribe() --- client.go | 5 +++++ options.go | 1 + 2 files changed, 6 insertions(+) diff --git a/client.go b/client.go index cb362120..b55d4699 100644 --- a/client.go +++ b/client.go @@ -656,6 +656,11 @@ func (c *client) Publish(topic string, qos byte, retained bool, payload interfac // Subscribe starts a new subscription. Provide a MessageHandler to be executed when // a message is published on the topic provided. +// +// Please note: you should try to keep the execution time of the callback to be +// as low as possible, especially when SetOrderMatters(true) (default) is in +// place. Blocking calls in message handlers might otherwise delay delivery to +// other message handlers. func (c *client) Subscribe(topic string, qos byte, callback MessageHandler) Token { token := newToken(packets.Subscribe).(*SubscribeToken) DEBUG.Println(CLI, "enter Subscribe") diff --git a/options.go b/options.go index 8c562791..0d5aac29 100644 --- a/options.go +++ b/options.go @@ -209,6 +209,7 @@ func (o *ClientOptions) SetCleanSession(clean bool) *ClientOptions { // each QoS level. By default, this value is true. If set to false, // this flag indicates that messages can be delivered asynchronously // from the client to the application and possibly arrive out of order. +// Specifically, the message handler is called in its own go routine. func (o *ClientOptions) SetOrderMatters(order bool) *ClientOptions { o.Order = order return o From b3085ba5da1cb8ea72e7ffdfc2cb13e0d6563dcf Mon Sep 17 00:00:00 2001 From: Chris Pahl Date: Mon, 8 Jun 2020 12:53:12 +0200 Subject: [PATCH 3/3] Sign off commit to get beyond CI Signed-off-by: Chris Pahl --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index b55d4699..b7795205 100644 --- a/client.go +++ b/client.go @@ -658,7 +658,7 @@ func (c *client) Publish(topic string, qos byte, retained bool, payload interfac // a message is published on the topic provided. // // Please note: you should try to keep the execution time of the callback to be -// as low as possible, especially when SetOrderMatters(true) (default) is in +// as low as possible, especially when SetOrderMatters(true) (the default) is in // place. Blocking calls in message handlers might otherwise delay delivery to // other message handlers. func (c *client) Subscribe(topic string, qos byte, callback MessageHandler) Token {