Universal Messaging 10.1 | Developer Guide | Enterprise APIs | Enterprise Developer's Guide for C++ | General Features | Google Protocol Buffers
Google Protocol Buffers
Google Protocol Buffers are a way of efficiently serializing structured data. They are language and platform neutral and have been designed to be easily extensible. The structure of your data is defined once, and then specific serialization and deserialization code is produced specifically to handle your data format efficiently.
Universal Messaging supports server-side filtering of Google Protocol Buffers, and this, coupled with Google Protocol Buffer's space-efficient serialization can be used to reduce the amount of data delivered to a client. If server side filtering is not required, the serialised protocol buffers could be loaded into a normal nConsume Event as the event data.
The structure of the data is defined in a .proto file, messages are constructed from a number of different types of fields and these fields can be required, optional or repeated. Protocol Buffers can also include other Protocol Buffers.
The serialization uses highly efficient encoding to make the serialized data as space efficient as possible, and the custom generated code for each data format allows for rapid serialization and deserialization.
Using Google Protocol Buffers with Universal Messaging
Google supplies libraries for Protocol Buffer in Java, C++ and Python, and third party libraries provide support for many other languages including .NET, Perl, PHP etc. Universal Messaging's client APIs provide support for the construction of Google Protocol Buffer event through which the serialized messages can be passed.
These nProtobufEvents are integrated seamlessly in nirvana, allowing for server-side filtering of Google Protocol Buffer events, which can be sent on resources just like a normal Universal Messaging events. The server side filtering of messages is achieved by providing the server with a description of the data structures(constructed at the .proto compile time, using the standard protobuf compiler and the --descriptor_set_out option). The default location the sever looks in for descriptor files is /plugins/ProtobufDescriptors and this can be configured through the enterprise manager. The server will monitor this folder for changes, and the frequency of these updates can be configured through the enterprise manager. The server can then use to extract the key value pairs from the binary Protobuf message and filter message delivery based on user requirements.
To create a nProtobuf event, simply build your protocol buffer as normal and pass it into the nProtobuf constructor along with the message type used.
nProtobuf events are received by subscribers in the normal way.
The Enterprise Manager can be used to view, edit and republish protocol buffer events, even if the EM is no running on the same machine as the server. To enable this, the server outputs a descriptor set to a configurable directory (by default the htdocs directory for the realm) and this can then be made available through a file plugin etc. The directory can be changed through the enterprise manager. The enterprise manager can then be configured to load this file using -DProtobufDescSetURL and then the contents of the protocol buffers can be parsed.