Java – AVRO avdl file generation

AVRO avdl file generation… here is a solution to the problem.

AVRO avdl file generation

I define the Person record as Avro IDL (person.avdl):

@namespace("net.tzolov.avro.extend")
protocol PersonProtocol {
    record Person {
        string firstName;
        string lastName;
    }     
}

I’m generating a java file, so this file is generating PersonProtocol.java and Person.java.
PersonProtocol.java is an empty file, is there any way to exclude the generation of this file….

Solution

You cannot rule out the generation of this file because Avro IDL defines a protocol (see more here.) )。

Your PersonProtocol .java is empty because you are not using RPC that provides the Avro IDL language.

For example:

@namespace("net.tzolov.avro.extend")
protocol PersonProtocol {
 record Person {
    string firstName;
    string lastName;
 }

string printMessage(string theMessage);    
}

By using code generation, you get a specific line that defines the RPC method:

void printMessage(java.lang.CharSequence theMessage, org.apache.avro.ipc.Callback<java.lang.CharSequence> callback) throws java.io.IOException;

If you only want to store data, you should use AVRO Schema (AVSC).

Related Problems and Solutions