Testing protocol buffers with VertX [JAVA]
Vert.x is a tool-kit for building reactive applications on the JVM. Protocol Buffers are a language-neutral, platform-neutral extensible mechanism for serializing structured data.
This sample deploys two verticles that transfer a simple object between them. The data is encoded using protocol buffers, and it is sent using the vert.x event-bus.
HelloRequest is used to define a simple object with a single property: name
HelloWorldProto is auto-generated by protoc.exe 4.3.0, from the proto file Simple.proto
SpeakerVerticle generates a HelloRequest object and convert it into message using protocol buffers generated HelloWorldProto.HelloRequest.Build
ListenerVerticle receives the message through vert.x's event-bus and convert is instantiate an object based on the message received.
Target folder holds executables compiled for Java8 on Win7. For Windows, batch files are available: build-verticles.bat and run-verticles.bat
UPDATE: In addition to sending the "news-feed" channel, a more complex message is sent at the "comm-feed" channel of the event-bus. PersonProto defines CommunicationMessage class that it's object may hold either Person or Location message reports. At the recepient side, ListenerVerticle verticle, the communication-message is parsed to determine the inner message within it. ProtoBuff construct HasPersonReport() and HasLocationReport() properties for this purpose...