Generate Protobuf message definitions from (Java) source

27 views
Skip to first unread message

Jawaid Hakim

unread,
Jul 23, 2020, 10:37:24 AM7/23/20
to Protocol Buffers
Hi,

Our platform inter-operates between .NET (frontend) and Java (backend), communication channel is pub/sub (JMS), and serialization is done using a reflection based framework. The allows the frontend and backend development teams to just 'drop' domain specific objects into message containers - the underlying framework does the rest. Development teams don't need to code up separate DTOs.

Looking at Protobuf as a potential replacement for the custom serialization framework. However, given the large body of existing business objects it would be a huge effort to write Protobuf message definitions manually. Also we'd like to have the developers focus on domain objects and not worry (too much) about Protobuf message definitions.

Is there a battle tested conversion tool/utility that generates Protobuf message from Java source? Such a tool could be part of the build pipeline and free developers from having to keep Protobuf messages refs in sync with domain specific objects.

Thanks!


Adam Cozzette

unread,
Jul 24, 2020, 1:47:26 PM7/24/20
to Jawaid Hakim, Protocol Buffers
I haven't heard of anything like this, though I guess it's possible that it exists out there. The thing that seems complicated to me is that the field numbers are very important and as you evolve your proto schema you have to be careful not to reuse the same field number for a different field type. As a result, the field numbers would have to somehow be derived from the Java source, which probably means that the developers would have to annotate them somewhere in Java. It seems to me like it would probably be easier to maintain the .proto files directly rather than have to learn a new setup for encoding the schema in Java. Maybe it would make sense to auto-generate the .proto files from Java as a one-time operation, and thereafter make all future schema changes directly in the .proto files.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/8372f62b-236f-423d-b09d-6ee345f42b31o%40googlegroups.com.

Derek Perez

unread,
Jul 24, 2020, 1:50:47 PM7/24/20
to Adam Cozzette, Jawaid Hakim, Protocol Buffers
This is a java-based library/API that could be used to create proto source files: https://github.com/perezd/protopoet.

Reply all
Reply to author
Forward
0 new messages