This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 4faaf16fc7ea CAMEL-27604: camel-google-firestore - realtime listener
errors, nested merge fields, operation default (#30996)
4faaf16fc7ea is described below
commit 4faaf16fc7eacc113ddf6ff9a94e0c63b948e9cc
Author: allthingssecurity <[email protected]>
AuthorDate: Fri Nov 27 22:16:54 2026 +0530
CAMEL-27604: camel-google-firestore - realtime listener errors, nested
merge fields, operation default (#30996)
1. With realtimeUpdates=true, an error of the snapshot listener was only
logged at ERROR level: it never reached the exception handler of the
consumer (or bridgeErrorHandler), and when it was the first event the
latch was not counted down, so doStart() waited the full 30 seconds,
ignored the result of the wait and logged that the listener had started.
Firestore does not call a listener again after an error, so the route
ran with a closed listener.
Now an error that arrives while doStart() waits for the first event
fails the start of the consumer with that FirestoreException (the
listener registration is removed). A later error goes to
getExceptionHandler(). When no event arrives within 30 seconds, a WARN
is logged instead of the "started" message, and the consumer still
starts, as before. The listener is now started before the scheduler of
the consumer, so a failed start does not leave the scheduler running.
The start state is shared with the listener thread under its own lock.
2. CamelGoogleFirestoreMergeFields mapped each name with FieldPath.of(name),
which takes the name as one segment, so address.city was a top-level
field literally named address.city. Names are now parsed with
FieldPath.fromDotSeparatedString, as the field paths of updateDocument
are. A FieldPath element in the list is used as it is, so a top-level
field whose name contains a dot can still be merged. A name that is not
a valid dot-separated path (one with ~ * / [ or ], which
fromDotSeparatedString rejects, or with an empty segment such as a..b)
is still taken with FieldPath.of(name) as one top-level field, so such
names keep working as before.
3. The operation option has defaultValue setDocument, the operation the
producer performs when neither the option nor the header is set.
Not changed: 4 (label advanced for firestoreClient). Advanced options move
to the Advanced builders of the Endpoint DSL, so
googleFirestore(...).firestoreClient(client) would no longer compile.
The doc page describes the listener errors and dotted merge field names;
upgrade guide entry for 4.24 for points 1 and 2. mockito-core is added as a
test dependency for the new tests. Regenerated google-firestore.json
(component and catalog copy), the catalog copy of the doc page and the
component and endpoint DSL javadoc.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../camel/catalog/components/google-firestore.json | 6 +-
.../catalog/docs/google-firestore-component.adoc | 8 +-
.../camel-google/camel-google-firestore/pom.xml | 6 +
.../google/firestore/google-firestore.json | 6 +-
.../src/main/docs/google-firestore-component.adoc | 8 +-
.../firestore/GoogleFirestoreConfiguration.java | 2 +-
.../google/firestore/GoogleFirestoreConstants.java | 5 +-
.../google/firestore/GoogleFirestoreConsumer.java | 57 ++++++++-
.../google/firestore/GoogleFirestoreProducer.java | 29 ++++-
.../GoogleFirestoreProducerMergeFieldsTest.java | 119 +++++++++++++++++++
.../GoogleFirestoreRealtimeListenerErrorTest.java | 131 +++++++++++++++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 14 +++
.../GoogleFirestoreComponentBuilderFactory.java | 2 +
.../dsl/GoogleFirestoreEndpointBuilderFactory.java | 9 +-
14 files changed, 381 insertions(+), 21 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/google-firestore.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/google-firestore.json
index b4449bd427be..8ff7a882752a 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/google-firestore.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/google-firestore.json
@@ -34,7 +34,7 @@
"maxPendingChanges": { "index": 7, "kind": "property", "displayName": "Max
Pending Changes", "group": "consumer (advanced)", "label": "consumer,advanced",
"required": false, "type": "integer", "javaType": "int", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 0, "configurationClass":
"org.apache.camel.component.google.firestore.GoogleFirestoreConfiguration",
"configurationField": "configuration", "description": "Maximum number of
realtime document changes bu [...]
"documentId": { "index": 8, "kind": "property", "displayName": "Document
Id", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.google.firestore.GoogleFirestoreConfiguration",
"configurationField": "configuration", "description": "The ID of the document
for setDocument, getDocumentById, updateDocument and deleteDocume [...]
"lazyStartProducer": { "index": 9, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
- "operation": { "index": 10, "kind": "property", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.google.firestore.GoogleFirestoreOperations",
"enum": [ "setDocument", "getDocumentById", "updateDocument", "deleteDocument",
"queryCollection", "listDocuments", "listCollections", "createDocument" ],
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.cam [...]
+ "operation": { "index": 10, "kind": "property", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.google.firestore.GoogleFirestoreOperations",
"enum": [ "setDocument", "getDocumentById", "updateDocument", "deleteDocument",
"queryCollection", "listDocuments", "listCollections", "createDocument" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"setDocument", "confi [...]
"autowiredEnabled": { "index": 11, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching [...]
"healthCheckConsumerEnabled": { "index": 12, "kind": "property",
"displayName": "Health Check Consumer Enabled", "group": "health", "label":
"health", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true,
"description": "Used for enabling or disabling all consumer based health checks
from this component" },
"healthCheckProducerEnabled": { "index": 13, "kind": "property",
"displayName": "Health Check Producer Enabled", "group": "health", "label":
"health", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true,
"description": "Used for enabling or disabling all producer based health checks
from this component. Notice: Camel has by default disabled all producer based
health-checks. You can turn on produce [...]
@@ -56,7 +56,7 @@
"CamelGoogleFirestoreResponseReadTime": { "index": 13, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "com.google.cloud.Timestamp", "deprecated": false, "autowired":
false, "secret": false, "description": "The time the document was read. The
consumer sets it for each document, and the producer for getDocumentById when
the document exists.", "constantName":
"org.apache.camel.component.google.firestore.GoogleFirestoreConstants#RESPON
[...]
"CamelGoogleFirestoreChangeType": { "index": 14, "kind": "header",
"displayName": "", "group": "consumer", "label": "consumer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The type of change reported by the realtime listener: ADDED,
MODIFIED or REMOVED. Only set when realtimeUpdates is enabled.",
"constantName":
"org.apache.camel.component.google.firestore.GoogleFirestoreConstants#CHANGE_TYPE"
},
"CamelGoogleFirestoreMerge": { "index": 15, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": "false", "description": "Whether setDocument merges the
fields of the body into the existing document instead of replacing the
document.", "constantName":
"org.apache.camel.component.google.firestore.GoogleFirestoreConstants#MERGE" },
- "CamelGoogleFirestoreMergeFields": { "index": 16, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "java.util.List<String>", "deprecated": false, "autowired": false,
"secret": false, "description": "The names of the fields that setDocument
merges when CamelGoogleFirestoreMerge is true. The other fields of the body are
ignored. If not set, all fields of the body are merged.", "constantName":
"org.apache.camel.component.googl [...]
+ "CamelGoogleFirestoreMergeFields": { "index": 16, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "java.util.List<String>", "deprecated": false, "autowired": false,
"secret": false, "description": "The names of the fields that setDocument
merges when CamelGoogleFirestoreMerge is true. A dotted name such as
address.city is the nested field city of address; a
com.google.cloud.firestore.FieldPath element is used as it is. The [...]
},
"bodyTypes": {
"consumerOut": { "carriers": [ "map" ], "description": "The fields of the
document as a Map, one message per document, with its id, path and times in
headers, and with realtimeUpdates the change type. Numbers are Long or Double,
a timestamp a com.google.cloud.Timestamp" },
@@ -77,7 +77,7 @@
"maxPendingChanges": { "index": 10, "kind": "parameter", "displayName":
"Max Pending Changes", "group": "consumer (advanced)", "label":
"consumer,advanced", "required": false, "type": "integer", "javaType": "int",
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 0,
"configurationClass":
"org.apache.camel.component.google.firestore.GoogleFirestoreConfiguration",
"configurationField": "configuration", "description": "Maximum number of
realtime document changes [...]
"pollStrategy": { "index": 11, "kind": "parameter", "displayName": "Poll
Strategy", "group": "consumer (advanced)", "label": "consumer,advanced",
"required": false, "type": "object", "javaType":
"org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false,
"autowired": false, "secret": false, "description": "A pluggable
org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your
custom implementation to control error handling usually occurred during the po
[...]
"documentId": { "index": 12, "kind": "parameter", "displayName": "Document
Id", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.google.firestore.GoogleFirestoreConfiguration",
"configurationField": "configuration", "description": "The ID of the document
for setDocument, getDocumentById, updateDocument and deleteDocu [...]
- "operation": { "index": 13, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.google.firestore.GoogleFirestoreOperations",
"enum": [ "setDocument", "getDocumentById", "updateDocument", "deleteDocument",
"queryCollection", "listDocuments", "listCollections", "createDocument" ],
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.ca [...]
+ "operation": { "index": 13, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.google.firestore.GoogleFirestoreOperations",
"enum": [ "setDocument", "getDocumentById", "updateDocument", "deleteDocument",
"queryCollection", "listDocuments", "listCollections", "createDocument" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"setDocument", "conf [...]
"lazyStartProducer": { "index": 14, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produ [...]
"backoffErrorThreshold": { "index": 15, "kind": "parameter",
"displayName": "Backoff Error Threshold", "group": "scheduler", "label":
"consumer,scheduler", "required": false, "type": "integer", "javaType": "int",
"deprecated": false, "autowired": false, "secret": false, "description": "The
number of subsequent error polls (failed due some error) that should happen
before the backoffMultipler should kick-in." },
"backoffIdleThreshold": { "index": 16, "kind": "parameter", "displayName":
"Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler",
"required": false, "type": "integer", "javaType": "int", "deprecated": false,
"autowired": false, "secret": false, "description": "The number of subsequent
idle polls that should happen before the backoffMultipler should kick-in." },
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/google-firestore-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/google-firestore-component.adoc
index d861955e7331..70768654ea2d 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/google-firestore-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/google-firestore-component.adoc
@@ -255,6 +255,12 @@
from("google-firestore://myCollection?realtimeUpdates=true&maxPendingChanges=100
.to("log:changes");
----
+When the consumer starts, it waits up to 30 seconds for the first snapshot of
the listener. If the listener reports an
+error instead, for example missing permissions or a database that does not
exist, the consumer fails to start with that
+error. Firestore does not call a listener again after an error, so an error
that comes later goes to the exception
+handler of the consumer (or to the routing error handler with
`bridgeErrorHandler=true`), and the route must be
+restarted to listen again.
+
=== Advanced Component Configuration
If you need more control over the `Firestore` client instance configuration,
you can create your own instance and refer to it in your Camel google-firestore
component configuration:
@@ -1170,7 +1176,7 @@ The component uses the following headers:
| `CamelGoogleFirestoreQueryOrderBy` | `String` | Field to order results by
| `CamelGoogleFirestoreQueryOrderDirection` | `Query.Direction` | Order
direction (ASCENDING/DESCENDING)
| `CamelGoogleFirestoreMerge` | `Boolean` | Merge data with existing document
-| `CamelGoogleFirestoreMergeFields` | `List<String>` | Specific fields to merge
+| `CamelGoogleFirestoreMergeFields` | `List<String>` | Specific fields to
merge; a dotted name such as `address.city` is a nested field
|===
=== Consumer/Response Headers (Output)
diff --git a/components/camel-google/camel-google-firestore/pom.xml
b/components/camel-google/camel-google-firestore/pom.xml
index f07593759e4d..dcc6cef1e7af 100644
--- a/components/camel-google/camel-google-firestore/pom.xml
+++ b/components/camel-google/camel-google-firestore/pom.xml
@@ -88,5 +88,11 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>${mockito-version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git
a/components/camel-google/camel-google-firestore/src/generated/resources/META-INF/org/apache/camel/component/google/firestore/google-firestore.json
b/components/camel-google/camel-google-firestore/src/generated/resources/META-INF/org/apache/camel/component/google/firestore/google-firestore.json
index b4449bd427be..8ff7a882752a 100644
---
a/components/camel-google/camel-google-firestore/src/generated/resources/META-INF/org/apache/camel/component/google/firestore/google-firestore.json
+++
b/components/camel-google/camel-google-firestore/src/generated/resources/META-INF/org/apache/camel/component/google/firestore/google-firestore.json
@@ -34,7 +34,7 @@
"maxPendingChanges": { "index": 7, "kind": "property", "displayName": "Max
Pending Changes", "group": "consumer (advanced)", "label": "consumer,advanced",
"required": false, "type": "integer", "javaType": "int", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 0, "configurationClass":
"org.apache.camel.component.google.firestore.GoogleFirestoreConfiguration",
"configurationField": "configuration", "description": "Maximum number of
realtime document changes bu [...]
"documentId": { "index": 8, "kind": "property", "displayName": "Document
Id", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.google.firestore.GoogleFirestoreConfiguration",
"configurationField": "configuration", "description": "The ID of the document
for setDocument, getDocumentById, updateDocument and deleteDocume [...]
"lazyStartProducer": { "index": 9, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
- "operation": { "index": 10, "kind": "property", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.google.firestore.GoogleFirestoreOperations",
"enum": [ "setDocument", "getDocumentById", "updateDocument", "deleteDocument",
"queryCollection", "listDocuments", "listCollections", "createDocument" ],
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.cam [...]
+ "operation": { "index": 10, "kind": "property", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.google.firestore.GoogleFirestoreOperations",
"enum": [ "setDocument", "getDocumentById", "updateDocument", "deleteDocument",
"queryCollection", "listDocuments", "listCollections", "createDocument" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"setDocument", "confi [...]
"autowiredEnabled": { "index": 11, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching [...]
"healthCheckConsumerEnabled": { "index": 12, "kind": "property",
"displayName": "Health Check Consumer Enabled", "group": "health", "label":
"health", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true,
"description": "Used for enabling or disabling all consumer based health checks
from this component" },
"healthCheckProducerEnabled": { "index": 13, "kind": "property",
"displayName": "Health Check Producer Enabled", "group": "health", "label":
"health", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true,
"description": "Used for enabling or disabling all producer based health checks
from this component. Notice: Camel has by default disabled all producer based
health-checks. You can turn on produce [...]
@@ -56,7 +56,7 @@
"CamelGoogleFirestoreResponseReadTime": { "index": 13, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "com.google.cloud.Timestamp", "deprecated": false, "autowired":
false, "secret": false, "description": "The time the document was read. The
consumer sets it for each document, and the producer for getDocumentById when
the document exists.", "constantName":
"org.apache.camel.component.google.firestore.GoogleFirestoreConstants#RESPON
[...]
"CamelGoogleFirestoreChangeType": { "index": 14, "kind": "header",
"displayName": "", "group": "consumer", "label": "consumer", "required": false,
"javaType": "String", "deprecated": false, "autowired": false, "secret": false,
"description": "The type of change reported by the realtime listener: ADDED,
MODIFIED or REMOVED. Only set when realtimeUpdates is enabled.",
"constantName":
"org.apache.camel.component.google.firestore.GoogleFirestoreConstants#CHANGE_TYPE"
},
"CamelGoogleFirestoreMerge": { "index": 15, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": "false", "description": "Whether setDocument merges the
fields of the body into the existing document instead of replacing the
document.", "constantName":
"org.apache.camel.component.google.firestore.GoogleFirestoreConstants#MERGE" },
- "CamelGoogleFirestoreMergeFields": { "index": 16, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "java.util.List<String>", "deprecated": false, "autowired": false,
"secret": false, "description": "The names of the fields that setDocument
merges when CamelGoogleFirestoreMerge is true. The other fields of the body are
ignored. If not set, all fields of the body are merged.", "constantName":
"org.apache.camel.component.googl [...]
+ "CamelGoogleFirestoreMergeFields": { "index": 16, "kind": "header",
"displayName": "", "group": "producer", "label": "producer", "required": false,
"javaType": "java.util.List<String>", "deprecated": false, "autowired": false,
"secret": false, "description": "The names of the fields that setDocument
merges when CamelGoogleFirestoreMerge is true. A dotted name such as
address.city is the nested field city of address; a
com.google.cloud.firestore.FieldPath element is used as it is. The [...]
},
"bodyTypes": {
"consumerOut": { "carriers": [ "map" ], "description": "The fields of the
document as a Map, one message per document, with its id, path and times in
headers, and with realtimeUpdates the change type. Numbers are Long or Double,
a timestamp a com.google.cloud.Timestamp" },
@@ -77,7 +77,7 @@
"maxPendingChanges": { "index": 10, "kind": "parameter", "displayName":
"Max Pending Changes", "group": "consumer (advanced)", "label":
"consumer,advanced", "required": false, "type": "integer", "javaType": "int",
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 0,
"configurationClass":
"org.apache.camel.component.google.firestore.GoogleFirestoreConfiguration",
"configurationField": "configuration", "description": "Maximum number of
realtime document changes [...]
"pollStrategy": { "index": 11, "kind": "parameter", "displayName": "Poll
Strategy", "group": "consumer (advanced)", "label": "consumer,advanced",
"required": false, "type": "object", "javaType":
"org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false,
"autowired": false, "secret": false, "description": "A pluggable
org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your
custom implementation to control error handling usually occurred during the po
[...]
"documentId": { "index": 12, "kind": "parameter", "displayName": "Document
Id", "group": "producer", "label": "producer", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.google.firestore.GoogleFirestoreConfiguration",
"configurationField": "configuration", "description": "The ID of the document
for setDocument, getDocumentById, updateDocument and deleteDocu [...]
- "operation": { "index": 13, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.google.firestore.GoogleFirestoreOperations",
"enum": [ "setDocument", "getDocumentById", "updateDocument", "deleteDocument",
"queryCollection", "listDocuments", "listCollections", "createDocument" ],
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.ca [...]
+ "operation": { "index": 13, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "producer", "required": false,
"type": "enum", "javaType":
"org.apache.camel.component.google.firestore.GoogleFirestoreOperations",
"enum": [ "setDocument", "getDocumentById", "updateDocument", "deleteDocument",
"queryCollection", "listDocuments", "listCollections", "createDocument" ],
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"setDocument", "conf [...]
"lazyStartProducer": { "index": 14, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produ [...]
"backoffErrorThreshold": { "index": 15, "kind": "parameter",
"displayName": "Backoff Error Threshold", "group": "scheduler", "label":
"consumer,scheduler", "required": false, "type": "integer", "javaType": "int",
"deprecated": false, "autowired": false, "secret": false, "description": "The
number of subsequent error polls (failed due some error) that should happen
before the backoffMultipler should kick-in." },
"backoffIdleThreshold": { "index": 16, "kind": "parameter", "displayName":
"Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler",
"required": false, "type": "integer", "javaType": "int", "deprecated": false,
"autowired": false, "secret": false, "description": "The number of subsequent
idle polls that should happen before the backoffMultipler should kick-in." },
diff --git
a/components/camel-google/camel-google-firestore/src/main/docs/google-firestore-component.adoc
b/components/camel-google/camel-google-firestore/src/main/docs/google-firestore-component.adoc
index d861955e7331..70768654ea2d 100644
---
a/components/camel-google/camel-google-firestore/src/main/docs/google-firestore-component.adoc
+++
b/components/camel-google/camel-google-firestore/src/main/docs/google-firestore-component.adoc
@@ -255,6 +255,12 @@
from("google-firestore://myCollection?realtimeUpdates=true&maxPendingChanges=100
.to("log:changes");
----
+When the consumer starts, it waits up to 30 seconds for the first snapshot of
the listener. If the listener reports an
+error instead, for example missing permissions or a database that does not
exist, the consumer fails to start with that
+error. Firestore does not call a listener again after an error, so an error
that comes later goes to the exception
+handler of the consumer (or to the routing error handler with
`bridgeErrorHandler=true`), and the route must be
+restarted to listen again.
+
=== Advanced Component Configuration
If you need more control over the `Firestore` client instance configuration,
you can create your own instance and refer to it in your Camel google-firestore
component configuration:
@@ -1170,7 +1176,7 @@ The component uses the following headers:
| `CamelGoogleFirestoreQueryOrderBy` | `String` | Field to order results by
| `CamelGoogleFirestoreQueryOrderDirection` | `Query.Direction` | Order
direction (ASCENDING/DESCENDING)
| `CamelGoogleFirestoreMerge` | `Boolean` | Merge data with existing document
-| `CamelGoogleFirestoreMergeFields` | `List<String>` | Specific fields to merge
+| `CamelGoogleFirestoreMergeFields` | `List<String>` | Specific fields to
merge; a dotted name such as `address.city` is a nested field
|===
=== Consumer/Response Headers (Output)
diff --git
a/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConfiguration.java
b/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConfiguration.java
index 1fc8f0676cb1..865cfd335f05 100644
---
a/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConfiguration.java
+++
b/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConfiguration.java
@@ -51,7 +51,7 @@ public class GoogleFirestoreConfiguration implements
Cloneable, GoogleCommonConf
+ " If not set, the client uses Application
Default Credentials.")
private String serviceAccountKey;
- @UriParam(label = "producer",
+ @UriParam(label = "producer", defaultValue = "setDocument",
description = "The operation that the producer performs. If not
set, the producer performs setDocument. The"
+ " CamelGoogleFirestoreOperation header replaces
this option.",
enums =
"setDocument,getDocumentById,updateDocument,deleteDocument,queryCollection,listDocuments,listCollections,createDocument")
diff --git
a/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConstants.java
b/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConstants.java
index 1d6aa377f059..27eacec62348 100644
---
a/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConstants.java
+++
b/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConstants.java
@@ -118,8 +118,9 @@ public final class GoogleFirestoreConstants {
@Metadata(label = "producer",
description = "The names of the fields that setDocument merges
when CamelGoogleFirestoreMerge is"
- + " true. The other fields of the body are
ignored. If not set, all fields"
- + " of the body are merged.",
+ + " true. A dotted name such as address.city is
the nested field city of address; a"
+ + " com.google.cloud.firestore.FieldPath element
is used as it is. The other fields of the"
+ + " body are ignored. If not set, all fields of
the body are merged.",
javaType = "java.util.List<String>")
public static final String MERGE_FIELDS =
"CamelGoogleFirestoreMergeFields";
diff --git
a/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConsumer.java
b/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConsumer.java
index f017b58f4a5b..12ec9bd54202 100644
---
a/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConsumer.java
+++
b/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreConsumer.java
@@ -67,11 +67,12 @@ public class GoogleFirestoreConsumer extends
ScheduledBatchPollingConsumer {
@Override
protected void doStart() throws Exception {
- super.doStart();
-
+ // the listener is started first, so a listener that fails does not
leave the scheduler of the consumer running
if (endpoint.getConfiguration().isRealtimeUpdates()) {
startRealtimeListener();
}
+
+ super.doStart();
}
@Override
@@ -92,17 +93,32 @@ public class GoogleFirestoreConsumer extends
ScheduledBatchPollingConsumer {
super.doStop();
}
- private void startRealtimeListener() {
+ private void startRealtimeListener() throws Exception {
String collectionName =
endpoint.getConfiguration().getCollectionName();
CollectionReference collection =
endpoint.getFirestoreClient().collection(collectionName);
CountDownLatch latch = new CountDownLatch(1);
+ // an error that the listener receives while doStart waits for the
first event fails the start; a later error
+ // goes to the exception handler of the consumer
+ ListenerStart start = new ListenerStart();
listenerRegistration = collection.addSnapshotListener(new
EventListener<QuerySnapshot>() {
@Override
public void onEvent(QuerySnapshot snapshots, FirestoreException e)
{
if (e != null) {
- LOG.error("Error listening to collection: {}",
collectionName, e);
+ synchronized (start) {
+ if (start.waiting) {
+ start.error = e;
+ latch.countDown();
+ return;
+ }
+ }
+ // Firestore does not call the listener again after an
error
+ getExceptionHandler().handleException(
+ "The realtime listener of collection " +
collectionName
+ + " failed and
receives no more changes. Restart the route to"
+ + " listen again.",
+ e);
return;
}
@@ -120,13 +136,42 @@ public class GoogleFirestoreConsumer extends
ScheduledBatchPollingConsumer {
}
});
+ boolean firstEvent = false;
+ boolean interrupted = false;
try {
- latch.await(30, TimeUnit.SECONDS);
- LOG.debug("Realtime listener started for collection: {}",
collectionName);
+ firstEvent = latch.await(30, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
+ interrupted = true;
LOG.warn("Interrupted while starting realtime listener");
}
+
+ FirestoreException error;
+ synchronized (start) {
+ start.waiting = false;
+ error = start.error;
+ }
+ if (error != null) {
+ listenerRegistration.remove();
+ listenerRegistration = null;
+ throw error;
+ }
+ if (firstEvent) {
+ LOG.debug("Realtime listener started for collection: {}",
collectionName);
+ } else if (!interrupted) {
+ LOG.warn("The realtime listener of collection {} received no
snapshot within 30 seconds. It keeps waiting,"
+ + " and the changes are consumed when they arrive.",
+ collectionName);
+ }
+ }
+
+ /**
+ * Whether doStart still waits for the first event of the realtime
listener, and the error the listener received
+ * meanwhile. Guarded by its own monitor, as the listener runs on a
Firestore client thread.
+ */
+ private static final class ListenerStart {
+ private boolean waiting = true;
+ private FirestoreException error;
}
/**
diff --git
a/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreProducer.java
b/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreProducer.java
index 7c3c5d6f5b8e..42932cc61a01 100644
---
a/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreProducer.java
+++
b/components/camel-google/camel-google-firestore/src/main/java/org/apache/camel/component/google/firestore/GoogleFirestoreProducer.java
@@ -21,6 +21,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
+import java.util.regex.Pattern;
import com.google.api.core.ApiFuture;
import com.google.cloud.firestore.CollectionReference;
@@ -52,6 +53,8 @@ public class GoogleFirestoreProducer extends DefaultProducer {
private static final Logger LOG =
LoggerFactory.getLogger(GoogleFirestoreProducer.class);
private static final ObjectMapper OBJECT_MAPPER =
JsonMapper.builderWithJackson2Defaults().build();
+ // the characters that FieldPath.fromDotSeparatedString rejects
+ private static final Pattern NOT_IN_DOT_SEPARATED_PATH =
Pattern.compile("[~*/\\[\\]]");
private final GoogleFirestoreEndpoint endpoint;
@@ -112,10 +115,10 @@ public class GoogleFirestoreProducer extends
DefaultProducer {
if (Boolean.TRUE.equals(merge)) {
@SuppressWarnings("unchecked")
- List<String> mergeFields =
exchange.getIn().getHeader(GoogleFirestoreConstants.MERGE_FIELDS, List.class);
+ List<Object> mergeFields =
exchange.getIn().getHeader(GoogleFirestoreConstants.MERGE_FIELDS, List.class);
if (mergeFields != null && !mergeFields.isEmpty()) {
List<FieldPath> fieldPaths = mergeFields.stream()
- .map(FieldPath::of)
+ .map(GoogleFirestoreProducer::toMergeFieldPath)
.toList();
future = docRef.set(data,
SetOptions.mergeFieldPaths(fieldPaths));
} else {
@@ -253,6 +256,28 @@ public class GoogleFirestoreProducer extends
DefaultProducer {
message.setBody(results);
}
+ /**
+ * A dotted name such as address.city is the nested field city of address,
as for updateDocument. A name that is not
+ * a valid dot-separated path (one with ~ * / [ or ], which
FieldPath.fromDotSeparatedString rejects, or with an
+ * empty segment as in a..b) is the name of one top-level field, as before
4.24. A FieldPath is used as it is (for a
+ * field whose name contains a dot).
+ */
+ private static FieldPath toMergeFieldPath(Object field) {
+ if (field instanceof FieldPath fieldPath) {
+ return fieldPath;
+ }
+ String name = field.toString();
+ if (isDotSeparatedPath(name)) {
+ return FieldPath.fromDotSeparatedString(name);
+ }
+ return FieldPath.of(name);
+ }
+
+ private static boolean isDotSeparatedPath(String name) {
+ return !name.isEmpty() && !name.startsWith(".") && !name.endsWith(".")
&& !name.contains("..")
+ && !NOT_IN_DOT_SEPARATED_PATH.matcher(name).find();
+ }
+
/**
* The document data plus its id and path. The snapshot data is copied
first: the returned map is handed to the
* route, and the id/path entries must not be written into the object the
SDK gave us.
diff --git
a/components/camel-google/camel-google-firestore/src/test/java/org/apache/camel/component/google/firestore/GoogleFirestoreProducerMergeFieldsTest.java
b/components/camel-google/camel-google-firestore/src/test/java/org/apache/camel/component/google/firestore/GoogleFirestoreProducerMergeFieldsTest.java
new file mode 100644
index 000000000000..261cee0ceaf5
--- /dev/null
+++
b/components/camel-google/camel-google-firestore/src/test/java/org/apache/camel/component/google/firestore/GoogleFirestoreProducerMergeFieldsTest.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.firestore;
+
+import java.util.List;
+import java.util.Map;
+
+import com.google.api.core.ApiFutures;
+import com.google.cloud.firestore.CollectionReference;
+import com.google.cloud.firestore.DocumentReference;
+import com.google.cloud.firestore.FieldPath;
+import com.google.cloud.firestore.Firestore;
+import com.google.cloud.firestore.SetOptions;
+import com.google.cloud.firestore.WriteResult;
+import org.apache.camel.CatalogCamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.util.json.JsonObject;
+import org.apache.camel.util.json.Jsoner;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * The CamelGoogleFirestoreMergeFields header of setDocument, with a mocked
Firestore client.
+ */
+class GoogleFirestoreProducerMergeFieldsTest {
+
+ private final DocumentReference document = mock(DocumentReference.class);
+ private DefaultCamelContext context;
+ private GoogleFirestoreProducer producer;
+
+ @BeforeEach
+ void setUp() throws Exception {
+ Firestore firestore = mock(Firestore.class);
+ CollectionReference collection = mock(CollectionReference.class);
+ when(firestore.collection("users")).thenReturn(collection);
+ when(collection.document("doc1")).thenReturn(document);
+ when(document.set(anyMap(),
any(SetOptions.class))).thenReturn(ApiFutures.immediateFuture(mock(WriteResult.class)));
+
+ context = new DefaultCamelContext();
+ context.getRegistry().bind("firestore", firestore);
+ context.start();
+ GoogleFirestoreEndpoint endpoint = context.getEndpoint(
+
"google-firestore://users?documentId=doc1&firestoreClient=#firestore",
GoogleFirestoreEndpoint.class);
+ producer = new GoogleFirestoreProducer(endpoint);
+ }
+
+ @AfterEach
+ void tearDown() {
+ context.stop();
+ }
+
+ private void setDocument(List<?> mergeFields) throws Exception {
+ Exchange exchange = new DefaultExchange(context);
+ exchange.getIn().setBody(Map.of("address", Map.of("city", "Rome")));
+ exchange.getIn().setHeader(GoogleFirestoreConstants.MERGE, true);
+ exchange.getIn().setHeader(GoogleFirestoreConstants.MERGE_FIELDS,
mergeFields);
+ producer.process(exchange);
+ }
+
+ @Test
+ void aDottedNameIsANestedField() throws Exception {
+ setDocument(List.of("address.city"));
+
+ verify(document).set(anyMap(), eq(
+ SetOptions.mergeFieldPaths(List.of(FieldPath.of("address",
"city")))));
+ }
+
+ @Test
+ void aFieldPathIsUsedAsItIs() throws Exception {
+ setDocument(List.of(FieldPath.of("address.city")));
+
+ verify(document).set(anyMap(), eq(
+
SetOptions.mergeFieldPaths(List.of(FieldPath.of("address.city")))));
+ }
+
+ @Test
+ void aNameThatIsNotADotSeparatedPathIsOneTopLevelField() throws Exception {
+ // FieldPath.fromDotSeparatedString rejects ~ * / [ ], and a..b has an
empty segment: such names are taken
+ // as they are, as before
+ setDocument(List.of("price/unit", "address..city"));
+
+ verify(document).set(anyMap(), eq(
+ SetOptions.mergeFieldPaths(List.of(FieldPath.of("price/unit"),
FieldPath.of("address..city")))));
+ }
+
+ @Test
+ void setDocumentIsTheDefaultOperationInTheMetadata() throws Exception {
+ JsonObject json = (JsonObject) Jsoner.deserialize(
+ ((CatalogCamelContext)
context).getComponentParameterJsonSchema("google-firestore"));
+ Map<String, Object> properties = json.getMap("properties");
+
+ assertThat(((Map<?, ?>)
properties.get("operation")).get("defaultValue")).isEqualTo("setDocument");
+ }
+}
diff --git
a/components/camel-google/camel-google-firestore/src/test/java/org/apache/camel/component/google/firestore/GoogleFirestoreRealtimeListenerErrorTest.java
b/components/camel-google/camel-google-firestore/src/test/java/org/apache/camel/component/google/firestore/GoogleFirestoreRealtimeListenerErrorTest.java
new file mode 100644
index 000000000000..35267d66cb31
--- /dev/null
+++
b/components/camel-google/camel-google-firestore/src/test/java/org/apache/camel/component/google/firestore/GoogleFirestoreRealtimeListenerErrorTest.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.firestore;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import com.google.cloud.firestore.CollectionReference;
+import com.google.cloud.firestore.EventListener;
+import com.google.cloud.firestore.Firestore;
+import com.google.cloud.firestore.FirestoreException;
+import com.google.cloud.firestore.ListenerRegistration;
+import com.google.cloud.firestore.QuerySnapshot;
+import io.grpc.Status;
+import org.apache.camel.Consumer;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.spi.ExceptionHandler;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * Errors of the realtime snapshot listener, with a mocked Firestore client:
the listener of the SDK does not get any
+ * more event after an error.
+ */
+class GoogleFirestoreRealtimeListenerErrorTest {
+
+ private final AtomicReference<EventListener<QuerySnapshot>> listener = new
AtomicReference<>();
+ private final ListenerRegistration registration =
mock(ListenerRegistration.class);
+ private final List<FirestoreException> firstEvents = new ArrayList<>();
+ private DefaultCamelContext context;
+ private Consumer consumer;
+
+ @BeforeEach
+ @SuppressWarnings("unchecked")
+ void setUp() {
+ Firestore firestore = mock(Firestore.class);
+ CollectionReference collection = mock(CollectionReference.class);
+ when(firestore.collection("users")).thenReturn(collection);
+ // the SDK calls the listener on its own thread; here the first event
(a snapshot or an error) is delivered at once
+
when(collection.addSnapshotListener(any(EventListener.class))).thenAnswer(invocation
-> {
+ EventListener<QuerySnapshot> eventListener =
invocation.getArgument(0);
+ listener.set(eventListener);
+ eventListener.onEvent(null, firstEvents.isEmpty() ? null :
firstEvents.get(0));
+ return registration;
+ });
+
+ context = new DefaultCamelContext();
+ context.getRegistry().bind("firestore", firestore);
+ context.start();
+ }
+
+ @AfterEach
+ void tearDown() {
+ context.stop();
+ }
+
+ private Consumer startConsumer() throws Exception {
+ GoogleFirestoreEndpoint endpoint = context.getEndpoint(
+
"google-firestore://users?realtimeUpdates=true&firestoreClient=#firestore",
GoogleFirestoreEndpoint.class);
+ consumer = endpoint.createConsumer(exchange -> {
+ });
+ consumer.start();
+ return consumer;
+ }
+
+ @Test
+ void anErrorAsTheFirstEventFailsTheStart() {
+ FirestoreException error
+ =
FirestoreException.forServerRejection(Status.PERMISSION_DENIED, "Missing or
insufficient permissions.");
+ firstEvents.add(error);
+
+ assertThatThrownBy(this::startConsumer).isSameAs(error);
+ verify(registration).remove();
+ }
+
+ @Test
+ void anErrorAfterTheStartGoesToTheExceptionHandler() throws Exception {
+ List<Throwable> handled = new ArrayList<>();
+ GoogleFirestoreEndpoint endpoint = context.getEndpoint(
+
"google-firestore://users?realtimeUpdates=true&firestoreClient=#firestore",
GoogleFirestoreEndpoint.class);
+ GoogleFirestoreConsumer realtime = (GoogleFirestoreConsumer)
endpoint.createConsumer(exchange -> {
+ });
+ realtime.setExceptionHandler(new ExceptionHandler() {
+ @Override
+ public void handleException(Throwable exception) {
+ handled.add(exception);
+ }
+
+ @Override
+ public void handleException(String message, Throwable exception) {
+ handled.add(exception);
+ }
+
+ @Override
+ public void handleException(String message, Exchange exchange,
Throwable exception) {
+ handled.add(exception);
+ }
+ });
+ consumer = realtime;
+ consumer.start();
+
+ FirestoreException error =
FirestoreException.forServerRejection(Status.NOT_FOUND, "The database does not
exist.");
+ listener.get().onEvent(null, error);
+
+ assertThat(handled).containsExactly(error);
+ }
+}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index c39fa1eded0e..fd53a8c8cfcd 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -12231,6 +12231,20 @@ that reads objects from one bucket and uploads them to
another now keeps the sto
before the objects got the default of the destination bucket. To keep the
previous behaviour, remove the header before
the upload, for example with
`removeHeader("CamelGoogleCloudStorageStorageClass")`.
+=== camel-google-firestore - realtime listener errors and nested merge fields
+
+A consumer with `realtimeUpdates=true` now fails to start when the first event
of the snapshot listener is an error,
+for example missing permissions or a database that does not exist. Before, the
error was only logged, the start waited
+30 seconds, and the route ran with a listener that Firestore had already
closed. An error that comes after the start
+now goes to the exception handler of the consumer (or the routing error
handler with `bridgeErrorHandler=true`)
+instead of only being logged at ERROR level.
+
+A name in the `CamelGoogleFirestoreMergeFields` header is now a dot-separated
field path, as for `updateDocument`:
+`address.city` merges the field `city` of the map `address`. Before, it was
taken as one top-level field named
+`address.city`. To merge a top-level field whose name contains a dot, put a
`com.google.cloud.firestore.FieldPath`
+(`FieldPath.of("address.city")`) in the list instead of the String. A name
that is not a valid dot-separated path,
+because it contains `~`, `*`, `/`, `[` or `]` or has an empty segment (as in
`a..b`), is still one top-level field.
+
=== camel-http-common, camel-netty-http, camel-http - a form field without =,
and a header whose name is not a token
A consumer that maps the fields of an `application/x-www-form-urlencoded`
request to headers (camel-servlet,
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/GoogleFirestoreComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/GoogleFirestoreComponentBuilderFactory.java
index ed476281527b..5335883f759b 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/GoogleFirestoreComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/GoogleFirestoreComponentBuilderFactory.java
@@ -252,6 +252,7 @@ public interface GoogleFirestoreComponentBuilderFactory {
return this;
}
+
/**
* The operation that the producer performs. If not set, the producer
* performs setDocument. The CamelGoogleFirestoreOperation header
@@ -260,6 +261,7 @@ public interface GoogleFirestoreComponentBuilderFactory {
* The option is a:
*
<code>org.apache.camel.component.google.firestore.GoogleFirestoreOperations</code>
type.
*
+ * Default: setDocument
* Group: producer
*
* @param operation the value to set
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GoogleFirestoreEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GoogleFirestoreEndpointBuilderFactory.java
index 2ef07c344a20..8ad14d2f6aac 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GoogleFirestoreEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GoogleFirestoreEndpointBuilderFactory.java
@@ -1024,6 +1024,7 @@ public interface GoogleFirestoreEndpointBuilderFactory {
* The option is a:
*
<code>org.apache.camel.component.google.firestore.GoogleFirestoreOperations</code>
type.
*
+ * Default: setDocument
* Group: producer
*
* @param operation the value to set
@@ -1041,6 +1042,7 @@ public interface GoogleFirestoreEndpointBuilderFactory {
* The option will be converted to a
*
<code>org.apache.camel.component.google.firestore.GoogleFirestoreOperations</code>
type.
*
+ * Default: setDocument
* Group: producer
*
* @param operation the value to set
@@ -1520,8 +1522,11 @@ public interface GoogleFirestoreEndpointBuilderFactory {
}
/**
* The names of the fields that setDocument merges when
- * CamelGoogleFirestoreMerge is true. The other fields of the body are
- * ignored. If not set, all fields of the body are merged.
+ * CamelGoogleFirestoreMerge is true. A dotted name such as
address.city
+ * is the nested field city of address; a
+ * com.google.cloud.firestore.FieldPath element is used as it is. The
+ * other fields of the body are ignored. If not set, all fields of the
+ * body are merged.
*
* The option is a: {@code java.util.List<String>} type.
*