Closed YannickWeber closed 2 years ago
Publishing user properties with the same name is possible. E.g.
UserProperty header1 = new UserProperty("app-id", "0000000000000000000"); UserProperty header2 = new UserProperty("app-id", "0000000000000000001"); UserProperty header3 = new UserProperty("trace-id", "0000000000000000002");
Only one user property with the duplicate name is present, when receiving the PUBLISH:
$ mqtt sub -t # -J { "topic": "my-topic", "payload": "test", "qos": "AT_LEAST_ONCE", "receivedAt": "2022-06-02 17:29:36", "retain": false, "userProperties": { "app-id": "0000000000000000001", "trace-id": "0000000000000000002" } }
public class Publisher { public static void main(final String[] args) throws MqttException { MqttClient client = new MqttClient("tcp://localhost:1883", "my-client"); client.connect(); MqttMessage message = new MqttMessage("test".getBytes(StandardCharsets.UTF_8)); MqttProperties proper = new MqttProperties(); List<UserProperty> userProperties = new ArrayList<>(); UserProperty header1 = new UserProperty("app-id", "0000000000000000000"); UserProperty header2 = new UserProperty("app-id", "0000000000000000001"); UserProperty header3 = new UserProperty("trace-id", "0000000000000000002"); userProperties.add(header1); userProperties.add(header2); userProperties.add(header3); proper.setUserProperties(userProperties); message.setProperties(proper); message.setQos(1); client.publish("my-topic", message); } }
I found out that this is an issue with my command line client.
Expected behaviour
Publishing user properties with the same name is possible. E.g.
Actual behaviour
Only one user property with the duplicate name is present, when receiving the PUBLISH:
Reproducer