Skip to content

Commit

Permalink
Merge pull request #14132 from nestjs/fix/mqtt-microservices-qos2
Browse files Browse the repository at this point in the history
fix(microservices): no messages emitted with mqtt when qos set
  • Loading branch information
kamilmysliwiec authored Nov 15, 2024
2 parents 831d295 + 1fe4dc2 commit 49dc36d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/microservices/client/client-mqtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,22 @@ export class ClientMqtt extends ClientProxy {
return undefined;
}

return {
...requestOptions,
properties: {
...requestOptions?.properties,
// Cant just spread objects as MQTT won't deliver
// any message with empty object as "userProperties" field
// @url https://github.com/nestjs/nest/issues/14079
let options: MqttRecordOptions = {};
if (requestOptions) {
options = { ...requestOptions };
}
if (this.options?.userProperties) {
options.properties = {
...options.properties,
userProperties: {
...this.options?.userProperties,
...requestOptions?.properties?.userProperties,
...options.properties?.userProperties,
},
},
};
};
}
return options;
}
}

0 comments on commit 49dc36d

Please sign in to comment.