Currently, when you marshal using camel-protobuf, it expects beforehand that you have already created your protobuf message as you can see here. I think is beneficial if the user can marshal the data automatically to protobuf provided he/she has the data in Map type and with the correct instance class name is provided. We can achieve this with the following steps:
- In marshal method, we check if the graph object of type Map.class.
- If it is of type Map.class, then using the defaultInstance.getDescriptorForType(), we obtain the Message Descriptor for the class instance.
- Using the obtained descriptor, we iterate over map value and set the field from the descriptor.
By using this, the user can marshal data to Protobuf without the need to process it before as long he/she has the data in type Map. I can send a PoC PR if you guys find my proposal reasonable enough but from my the top of my head, it shouldn't be much of work to add this feature to camel-protobuf