How to use FlatBuffers with GRPC in Java

782 views
Skip to first unread message

Rajan Shah

unread,
Jun 21, 2021, 2:59:02 AM6/21/21
to FlatBuffers
I am looking for a way to use FlatBuffers with GRPC in Java.  I am unable to find any documentation which says how to do it. 

From what I read support was added in version 1.9


Wouter van Oortmerssen

unread,
Jun 21, 2021, 1:46:48 PM6/21/21
to Rajan Shah, FlatBuffers
Looks like your best bet is checking out the gRPC test here: https://github.com/google/flatbuffers/blob/master/grpc/tests/JavaGrpcTest.java

On Sun, Jun 20, 2021 at 11:59 PM Rajan Shah <rajan....@gmail.com> wrote:
I am looking for a way to use FlatBuffers with GRPC in Java.  I am unable to find any documentation which says how to do it. 

From what I read support was added in version 1.9


--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flatbuffers/d9fb0734-acb5-4b7d-94ca-31f905193de0n%40googlegroups.com.

Rajan Shah

unread,
Jun 21, 2021, 7:08:33 PM6/21/21
to Wouter van Oortmerssen, FlatBuffers
I was looking for a way to use GRPC and FlatBuffers. I needed all the steps to generate the stubs and then I knew how to use them. Fortunately I found the answers. Giving it here so others can get it

1. First we need to get flatc  Ref https://google.github.io/flatbuffers/flatbuffers_guide_building.html
2. Use flatc to generate stubs which we can use in the program to create a client or server.  There is a maven plugin which can be used to generate the stubs Ref: https://github.com/yfinkelstein/flatbuffers-java

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <phase>generate-sources</phase>
                </execution>
            </executions>
            <configuration>
                <executable>${project.build.directory}/bin/flatc</executable>

                <!-- optional -->
                <workingDirectory>${fbs.sources}</workingDirectory>
                <arguments>
                    <argument>--java</argument>
                    <argument>--gen-all</argument>
                    <argument>--gen-mutable</argument>

                    <argument>--grpc</argument>
                    <argument>-o</argument>
                    <argument>${fbs.generated.sources}</argument>
                    <argument>Greetings.fbs</argument>
                </arguments>
            </configuration>
        </plugin>
Reply all
Reply to author
Forward
0 new messages