// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-grpc"]
= gRPC
:page-aliases: extensions/grpc.adoc
:linkattrs:
:cq-artifact-id: camel-quarkus-grpc
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Expose gRPC endpoints and access external gRPC endpoints.
:cq-deprecated: false
:cq-jvm-since: 1.0.0
:cq-native-since: 1.0.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native since##[.badge-supported]##1.0.0##
endif::[]

Expose gRPC endpoints and access external gRPC endpoints.

[id="extensions-grpc-whats-inside"]
== What's inside

* xref:{cq-camel-components}::grpc-component.adoc[gRPC component], URI syntax: `grpc:host:port/service`

Please refer to the above link for usage and configuration details.

[id="extensions-grpc-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-grpc[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-grpc</artifactId>
</dependency>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-grpc-usage"]
== Usage
[id="extensions-grpc-usage-protobuf-generated-code"]
=== 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.

[source,xml]
----
<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.

[id="extensions-grpc-usage-scanning-proto-files-with-imports"]
==== 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`.

[id="extensions-grpc-usage-scanning-proto-files-from-dependencies"]
==== 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.

[source,properties]
----
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.

[source,properties]
----
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
----

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

[id="extensions-grpc-usage-accessing-classpath-resources-in-native-mode"]
=== 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.

[source,properties]
----
quarkus.native.resources.includes = certs/*.pem,certs.*.key
----

More information about selecting resources for inclusion in the native executable can be found in the xref:user-guide/native-mode.adoc#embedding-resource-in-native-executable[native mode guide].


[id="extensions-grpc-camel-quarkus-limitations"]
== Camel Quarkus limitations

[id="extensions-grpc-limitations-integration-with-quarkus-grpc-is-not-supported"]
=== 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.


[id="extensions-grpc-additional-camel-quarkus-configuration"]
== Additional Camel Quarkus configuration

[width="100%",cols="80,5,15",options="header"]
|===
| Configuration property | Type | Default


|icon:lock[title=Fixed at build time] [[quarkus.camel.grpc.codegen.enabled]]`link:#quarkus.camel.grpc.codegen.enabled[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`

|icon:lock[title=Fixed at build time] [[quarkus.camel.grpc.codegen.scan-for-proto]]`link:#quarkus.camel.grpc.codegen.scan-for-proto[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`

|icon:lock[title=Fixed at build time] [[quarkus.camel.grpc.codegen.scan-for-imports]]`link:#quarkus.camel.grpc.codegen.scan-for-imports[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`

|icon:lock[title=Fixed at build time] [[quarkus.camel.grpc.codegen.scan-for-proto-includes.-scan-for-proto-includes]]`link:#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>>`
| 

|icon:lock[title=Fixed at build time] [[quarkus.camel.grpc.codegen.scan-for-proto-excludes.-scan-for-proto-excludes]]`link:#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-legend]
{doc-link-icon-lock}[title=Fixed at build time] Configuration property fixed at build time. All other configuration properties are overridable at runtime.

