Skip to content

Commit

Permalink
Mqtt max inflight: add parameter
Browse files Browse the repository at this point in the history
Export the mqtt max inflight messages settings to transport api
to increase the troughput in case of many messages from a gateway
  • Loading branch information
GwendalRaoul committed Jul 1, 2020
1 parent 198e860 commit 2a8b3a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python_transport/wirepas_gateway/protocol/mqtt_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def __init__(
self.logger.error("Cannot use secure authentication %s", e)
exit(-1)

self.logger.info(
"Max inflight messages set to %s", settings.mqtt_max_inflight_messages
)
self._client.max_inflight_messages_set(settings.mqtt_max_inflight_messages)

self._client.username_pw_set(settings.mqtt_username, settings.mqtt_password)
self._client.on_connect = self._on_connect
self._client.on_publish = self._on_publish
Expand Down
8 changes: 8 additions & 0 deletions python_transport/wirepas_gateway/utils/argument_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ def add_mqtt(self):
),
)

self.mqtt.add_argument(
"--mqtt_max_inflight_messages",
default=os.environ.get("WM_SERVICES_MQTT_MAX_INFLIGHT_MESSAGES", 20),
action="store",
type=self.str2int,
help=("Max inflight messages for messages with qos > 0"),
)

def add_buffering_settings(self):
""" Parameters used to avoid black hole case """
self.buffering.add_argument(
Expand Down

0 comments on commit 2a8b3a9

Please sign in to comment.