title: RabbitMQ in Java using Protobuf. Parse received data
body: <p>I am currently using springAMQP to communicate between java and my RabbitMQ node.
  I am sending Protobuf data.</p>
  
  <p>I would like to convert/cast/parse the received Message into the respective ProtoClass. </p>
  
  <p>Here is the snippet from my Converter:</p>
  
  <pre><code>@Override
  protected Message createMessage(Object object, MessageProperties messageProperties) {
      Preconditions.checkNotNull(object, "Object to send is null !");
  
      if (!com.google.protobuf.Message.class.isAssignableFrom(object.getClass())) {
          throw new MessageConversionException("Message wasn't a protobuf");
      } else {
          com.google.protobuf.Message protobuf = (com.google.protobuf.Message) object;
          byte[] byteArray = protobuf.toByteArray();
  
          messageProperties.setContentLength(byteArray.length);
          messageProperties.setContentType(ProtobufMessageConverter.CONTENT_TYPE_PROTOBUF);
          messageProperties.setHeader(ProtobufMessageConverter.MESSAGE_TYPE_NAME, protobuf.getDescriptorForType().getName());
  
          return new Message(byteArray, messageProperties);
      }
  }
  
  @Override
  public Object fromMessage(Message message) throws MessageConversionException {
  
      com.google.protobuf.Message parsedMessage = null;
      try {
          if(ProtobufMessageConverter.CONTENT_TYPE_PROTOBUF.equals(message.getMessageProperties().getContentType())) {
              String typeName = getMessageTypeName(message);
              Descriptors.Descriptor messageType = fileDescriptor.findMessageTypeByName(typeName);
              parsedMessage = DynamicMessage.parseFrom(messageType, message.getBody());
          }
      } catch (Exception e) {
          throw new AmqpRejectAndDontRequeueException("Cannot convert, unknown message type %s".format(getMessageTypeName(message)));
      }
      return parsedMessage;
  }
  </code></pre>
  
  <p>What do I have to do to be able to build the object?</p>
  
  <p>Here is my proto file:</p>
  
  <pre><code>message queueReply {
      required string identifier = 1; cycle
      required uint32 keyId = 2;
      required bool success = 3; 
      required bytes result = 4; 
  }
  </code></pre>
  
  <p>I would like to obtain the class queueReply from template.receiveAndConvert()</p>