Skip to content

Steps to Generate

Generate a gRPC connector from a Proto definition

This section explains how to generate a gRPC connector from a .proto file using the WSO2 Integrator: MI Connector Generator tool. The gRPC connector enables seamless communication between services, facilitating integration with systems that expose gRPC APIs. By utilizing a .proto file, which defines the service and message structure, the connector is automatically generated, allowing you to implement a fully functional gRPC client in your integration.

Prerequisites

Before you begin, ensure you have the following:

  • Java Development Kit (JDK) 8 or later
  • Apache Maven 3.6.x or higher

Steps to generate the connector

There are two ways of generating a gRPC connector from a .proto file:

  1. Using the WSO2 Integrator: MI for VS Code extension: This method allows you to generate a connector directly from the VS Code IDE.
  2. Using the WSO2 MI Connector Tooling: This method involves using a command-line tool to generate the connector from a .proto file.

Option 01: Using the WSO2 Integrator: MI for VS Code extension

Follow the steps below to generate the gRPC connector:

  1. Launch Visual Studio Code with the MI for VS Code extension installed.

    Info

    Follow the Install WSO2 Integrator: MI for VS Code documentation for a complete installation guide.

  2. Create a new integration project.

    Click Create New Project on WSO2 Integrator: MI Project Explorer. For more options to create a new integration project, see Create an Integration Project.

  3. Navigate to the Project Overview page.

  4. Add a new artifact by clicking on Add artifact.

    add artifact

  5. Click on + View More under Create an Integration.

  6. Select Connections under Other Artifacts to open the Connector Store form.

    connections artifact

  7. Click on the For gRPC (Proto)

    connections artifact

  8. Then select a location for the .proto file and click the import

  9. If the given proto file is valid, You can view the generated connection type in the Connections.

    generated connector

  10. To use the connector operations, you can create an integration artifact (such as API and sequence) and add it from the Mediator Palette.

    generated connector

Option 02: Using the WSO2 MI Connector Tooling

Follow the steps below to generate the gRPC connector:

  1. Fork the MI connector tooling repository

  2. Build the project using maven

    • Navigate to your project directory (<PROJECT_HOME>/) and build the project using Maven:
    mvn clean install
    
  3. Locate the tool

    • Once built, the tool will be packaged as a zip file: mi-connector-generator-{version}.zip.
    • You can find this file in the <PROJECT_HOME>/target directory.
  4. Extract the tool

    • Extract the mi-connector-generator-{version}.zip file to your preferred location.
  5. Run the connector generator

    • Navigate to the extracted folder and go to the bin directory.

    • For macOS/Linux: Use generate.sh:

    ./generator <proto-file> <output-directory> [miVersion]
    
    • For Windows: Use generate.bat:
    generator.bat <proto-file> <output-directory> [miVersion]
    
    • Replace:

      • <proto-file> with the path to your .proto file.
      • <output-directory> with the path where you want the connector to be generated.
      • [miVersion] with your specific WSO2 Integrator: MI version.
Example command

For macOS/Linux:

./generator /path/to/order-service.proto /path/to/output-directory 4.7.0

For Windows:

generator.bat C:\path\to\order-service.proto C:\path\to\output-directory 4.7.0

By following these steps, you can generate a fully functional gRPC connector from a .proto file, enabling seamless integration with gRPC-based services in WSO2 Integrator: MI.

Steps to import generated connector
  1. Navigate to the Mediator Palette page
  2. Select the Add Module under the Mediator Palette.

    generated connector

  3. Select Import Module

    import connector

  4. Select Location to upload the generated connector. After providing the generated connector zip file, click Import

    generated connector

  5. You can view the connector type in the Connections

    generated connector

  6. To use the connector operations, you can create an integration artifact (such as API and sequence) and add it from the Mediator Palette.

    generated connector

Note

The gRPC Connector Generator does not yet handle:

  • Streaming RPCs : server, client, or bidirectional streams
  • Custom .proto options: e.g., deadline, any other non-standard option fields
  • Specific data types: oneof unions and deeply nested complex structures

For the full list of features the tool does support, see the gRPC generator tool specification guide.