2.45. gRPC


Expose gRPC endpoints and access external gRPC endpoints.

2.45.1. What’s inside

Refer to the above link for usage and configuration details.

2.45.2. Maven coordinates

Create a new project with this extension on code.camel.redhat.com

Or add the coordinates to your existing project:

<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-grpc</artifactId>
</dependency>

2.45.3. Usage

2.45.3.1. Protobuf generated code

Camel Quarkus gRPC can generate gRPC service stubs for .proto files. When using Maven, ensure that you have enabled the generate-code goals of the quarkus-maven-plugin in your project build.

<build>
    <plugins>
        <plugin>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-maven-plugin</artifactId>
            <version>${quarkus.platform.version}</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <goals>
                        <goal>build</goal>
                        <goal>generate-code</goal>
                        <goal>generate-code-tests</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

With this configuration, you can put your service and message definitions into the src/main/proto directory and the quarkus-maven-plugin will generate code from your .proto files.

2.45.3.1.1. Scanning proto files with imports

The Protocol Buffers specification provides a way to import proto files. You can control the scope of dependencies to scan by adding configuration property quarkus.camel.grpc.codegen.scan-for-imports property to application.properties. The available options are outlined below.

  • all - Scan all dependencies
  • none - Disable dependency scanning. Use only the proto definitions defined in src/main/proto or src/test/proto
  • groupId1:artifactId1,groupId2:artifactId2 - Scan only the dependencies matching the groupId and artifactId list

The default value is com.google.protobuf:protobuf-java.

2.45.3.1.2. Scanning proto files from dependencies

If you have proto files shared across multiple dependencies, you can generate gRPC service stubs for them by adding configuration property quarkus.camel.grpc.codegen.scan-for-proto to application.properties.

First add a dependency for the artifact(s) containing proto files to your project. Next, enable proto file dependency scanning.

quarkus.camel.grpc.codegen.scan-for-proto=org.my.groupId1:my-artifact-id-1,org.my.groupId2:my-artifact-id-2

It is possible to include / exclude specific proto files from dependency scanning via configuration properties.

The configuration property name suffix is the Maven groupId / artifactId for the dependency to configure includes / excludes on. Paths are relative to the classpath location of the proto files within the dependency. Paths can be an explicit path to a proto file, or as glob patterns to include / exclude multiple files.

quarkus.camel.grpc.codegen.scan-for-proto-includes."<groupId>\:<artifactId>"=foo/**,bar/**,baz/a-proto.proto
quarkus.camel.grpc.codegen.scan-for-proto-excludes."<groupId>\:<artifactId>"=foo/private/**,baz/another-proto.proto
注記

The : character within property keys must be escaped with \.

2.45.3.2. Accessing classpath resources in native mode

The gRPC component has various options where resources are resolved from the classpath:

  • keyCertChainResource
  • keyResource
  • serviceAccountResource
  • trustCertCollectionResource

When using these options in native mode, you must ensure that any such resources are included in the native image.

This can be accomplished by adding the configuration property quarkus.native.resources.includes to application.properties. For example, to include SSL / TLS keys and certificates.

quarkus.native.resources.includes = certs/*.pem,certs.*.key

More information about selecting resources for inclusion in the native executable can be found in the native mode guide.

2.45.4. Camel Quarkus limitations

2.45.4.1. Integration with Quarkus gRPC is not supported

At present there is no support for integrating Camel Quarkus gRPC with Quarkus gRPC. If you have both the camel-quarkus-grpc and quarkus-grpc extension dependency on the classpath, you are likely to encounter problems at build time when compiling your application.

2.45.5. Additional Camel Quarkus configuration

Expand
Configuration propertyTypeDefault

quarkus.camel.grpc.codegen.enabled

If true, Camel Quarkus gRPC code generation is run for .proto files discovered from the proto directory, or from dependencies specified in the scan-for-proto or scan-for-imports options. When false, code generation for .proto files is disabled.

boolean

true

quarkus.camel.grpc.codegen.scan-for-proto

Camel Quarkus gRPC code generation can scan application dependencies for .proto files to generate Java stubs from them. This property sets the scope of the dependencies to scan. Applicable values:

- none - default - don’t scan dependencies - a comma separated list of groupId:artifactId coordinates to scan - all - scan all dependencies

string

none

quarkus.camel.grpc.codegen.scan-for-imports

Camel Quarkus gRPC code generation can scan dependencies for .proto files that can be imported by protos in this applications. Applicable values:

- none - default - don’t scan dependencies - a comma separated list of groupId:artifactId coordinates to scan - all - scan all dependencies The default is com.google.protobuf:protobuf-java.

string

com.google.protobuf:protobuf-java

[[quarkus-camel-grpc-codegen-scan-for-proto-includes—​scan-for-proto-includes]] quarkus.camel.grpc.codegen.scan-for-proto-includes."scan-for-proto-includes"

Package path or file glob pattern includes per dependency containing .proto files to be considered for inclusion.

Map<String,List<String>>

 

[[quarkus-camel-grpc-codegen-scan-for-proto-excludes—​scan-for-proto-excludes]] quarkus.camel.grpc.codegen.scan-for-proto-excludes."scan-for-proto-excludes"

Package path or file glob pattern includes per dependency containing .proto files to be considered for exclusion.

Map<String,List<String>>

 

Configuration property fixed at build time. All other configuration properties are overridable at runtime.

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る