Error: Illegal wire type for field Message.Field .protobuf.MessageTypeAck.sourceModuleID: 1 (0 expected)
<p>I've app that procude&amp;consume message with kafka and protocol buffer and everything works great. I'm serialize the protocol buffer with <code>SerializeAsString()</code> (this app was written in c++).</p>

<p>Now, I've added new node.js website that also consume messages and try to decode them.</p>

<p><strong>My js code (using the great <a href="https://github.com/dcodeIO/ProtoBuf.js" rel="nofollow">ProtoBuf.js</a> module):</strong></p>

<pre><code>var builder = ProtoBuf.loadProtoFile("/home/aii/general/proto/All.proto"),
    protobuf = builder.build("protobuf"),
    Trace = protobuf.Trace,
    MessageType = protobuf.MessageType,
    MessageTypeAck = protobuf.MessageTypeAck,
    MessageTypeKeepAlive = protobuf.MessageTypeKeepAlive;

function getMessageType(val) {
  return Object.keys(MessageType).filter(function(key) {return MessageType[key] === val})[0]
}

consumer.on('message', function (message) {
    try{
      switch(getMessageType(message.key[0])) {
        case 'MESSAGE_TYPE_ACK':
          console.log(MessageTypeAck.decode(message.value));
          break;
        case 'MESSAGE_TYPE_KEEP_ALIVE':
          console.log(MessageTypeKeepAlive.decode(message.value));
          break;
        default:
          console.log("Unknown message type");
      }
    } catch (e){
      if (e.decoded) {
        var err = e.decoded;
        console.log(err);
      }
      else {
        console.log(e);
      }
    }
});
</code></pre>

<p>Result:</p>

<pre><code>[Error: Illegal wire type for field Message.Field .protobuf.MessageTypeAck.sourceModuleID: 1 (0 expected)]
</code></pre>

<p>My proto files:</p>

<p><strong>Trace.proto:</strong></p>

<pre><code>package protobuf;

message Trace {
    optional string topic = 1;
    optional int32 partition = 2;
    optional int64 offset = 3;
}
</code></pre>

<p><strong>MessageType.proto</strong></p>

<pre><code>package protobuf;

enum MessageType {
    MESSAGE_TYPE_ACK = 1;
    MESSAGE_TYPE_KEEP_ALIVE = 2;
}
</code></pre>

<p><strong>Messages.proto:</strong></p>

<pre><code>import "Trace.proto";

package protobuf;

message MessageTypeAck {
    repeated Trace trace = 1;

    optional string sourceModuleName = 2;
    optional int32  sourceModuleID   = 3;
}

message MessageTypeKeepAlive {
    repeated Trace trace = 1;

    optional string sourceModuleName = 2;
    optional int32  sourceModuleID   = 3;
}
</code></pre>

<p><strong>All.proto</strong></p>

<pre><code>import "Trace.proto"
import "MessageType.proto";
import "Messages.proto"
</code></pre>

<p>What am I doing wrong? (decode?)</p>