Repository: netty/netty
Issue: Not specified field in MQTT codec

### Expected behavior
According to the [MQTT 3.1.1 spec](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/csprd02/mqtt-v3.1.1-csprd02.html), the variable header must not have a messageId in the variable header when publishing PUBLISH packet. It must have only these two: Topic Name and Packet Identifier.

### Actual behavior
In io.netty.handler.codec.mqtt.MqttPublishVariableHeader there are two fields and one of them is messageId which is not specified.

### Question
What the meaning of messageId field in MqttPublishVariableHeader?

Thank you,
Pavel



Issue comments:
@mousom - ping (for reference see [1])

@Sammers21 - You can see how PUBLISH is encoded here [2]. Do you think there is an issue with this?

[1] http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/csprd02/mqtt-v3.1.1-csprd02.html#_Toc385349775
[2] https://github.com/netty/netty/blob/4.1/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttEncoder.java#L298
@Scottmitch, After reading how PUBLISH packet encodes I would assume that messageId in code is the same thing as Packet Identifier in spec. Maybe it would be better to rename messageId field into packetId? 
Can I create PR?
@Sammers21 I think we can not rename interface methods as we otherwise would break user-code or you talking about something else ?
@normanmaurer, yes, you are right, renaming of one of the fields would break user code. But in my point of view, fields should are named in the same way as it in a protocol otherwise it can be tricky for new users to understand what the field really mean.
If you want to submit a PR to correct naming you can deprecate the existing accessors and refer to the new accessors (if you think its worth it).
@Scottmitch , I have marked the old method with @deprecated  and opened PR. Check it out.

Pull request review comments:

Patch that resolved the issue:
diff --git a/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttPublishVariableHeader.java b/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttPublishVariableHeader.java
index 6422d53b901..a0d0481b14c 100644
--- a/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttPublishVariableHeader.java
+++ b/codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttPublishVariableHeader.java
@@ -24,19 +24,27 @@
 public final class MqttPublishVariableHeader {
 
     private final String topicName;
-    private final int messageId;
+    private final int packetId;
 
-    public MqttPublishVariableHeader(String topicName, int messageId) {
+    public MqttPublishVariableHeader(String topicName, int packetId) {
         this.topicName = topicName;
-        this.messageId = messageId;
+        this.packetId = packetId;
     }
 
     public String topicName() {
         return topicName;
     }
 
+    /**
+     * @deprecated Use {@link #packetId()} instead.
+     */
+    @Deprecated
     public int messageId() {
-        return messageId;
+        return packetId;
+    }
+
+    public int packetId() {
+        return packetId;
     }
 
     @Override
@@ -44,7 +52,7 @@ public String toString() {
         return new StringBuilder(StringUtil.simpleClassName(this))
             .append('[')
             .append("topicName=").append(topicName)
-            .append(", messageId=").append(messageId)
+            .append(", packetId=").append(packetId)
             .append(']')
             .toString();
     }


Test patch: