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-kamelets.git


The following commit(s) were added to refs/heads/main by this push:
     new 486f487d6 chore: aws-bedrock-agent-runtime-sink can retrieve passages 
and ask an agent, and the Redshift Kamelets can size their connection pool 
(#3170) (#3232)
486f487d6 is described below

commit 486f487d6881d0c581289113ed5d4eb2dbadddaa
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 18 22:37:24 2026 +0100

    chore: aws-bedrock-agent-runtime-sink can retrieve passages and ask an 
agent, and the Redshift Kamelets can size their connection pool (#3170) (#3232)
    
    aws-bedrock-agent-runtime-sink takes `operation`: `retrieveAndGenerate`
    (the default, as before), `retrieve` and `invokeAgent`. For `retrieve`,
    `numberOfResults` and `searchType` set the vector search of the request,
    through the headers the component reads, and only when they are set.
    For `invokeAgent`, `agentId` and `agentAliasId` go on the endpoint.
    `modelId` and `knowledgeBaseId` are no longer required, as `invokeAgent`
    uses neither and `retrieve` no model; they are now optional placeholders.
    With the new options unset, the endpoint URI is the same as before.
    
    aws-redshift-source and aws-redshift-sink take `maxTotal`, `maxIdle` and
    `maxWaitMillis` for the commons-dbcp2 data source, with the names and
    wording of the other SQL Kamelets.
    
    aws-bedrock-text-sink is unchanged: the converse operation reads the
    conversation only from a header holding AWS SDK objects, which a Kamelet
    user cannot set, and the guardrail options apply only to converse.
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 ...aws-bedrock-agent-runtime-sink-description.adoc | 57 +++++++++++++++
 .../partials/aws-redshift-sink-description.adoc    | 16 +++++
 .../partials/aws-redshift-source-description.adoc  | 20 ++++++
 .../aws-bedrock-agent-runtime-sink.kamelet.yaml    | 80 ++++++++++++++++++----
 kamelets/aws-redshift-sink.kamelet.yaml            | 18 +++++
 kamelets/aws-redshift-source.kamelet.yaml          | 18 +++++
 .../main/resources/META-INF/kamelets-index.json    |  4 +-
 .../aws-bedrock-agent-runtime-sink.kamelet.yaml    | 80 ++++++++++++++++++----
 .../kamelets/aws-redshift-sink.kamelet.yaml        | 18 +++++
 .../kamelets/aws-redshift-source.kamelet.yaml      | 18 +++++
 10 files changed, 301 insertions(+), 28 deletions(-)

diff --git 
a/docs/modules/ROOT/partials/aws-bedrock-agent-runtime-sink-description.adoc 
b/docs/modules/ROOT/partials/aws-bedrock-agent-runtime-sink-description.adoc
index 290c1dc16..b4fadea15 100644
--- a/docs/modules/ROOT/partials/aws-bedrock-agent-runtime-sink-description.adoc
+++ b/docs/modules/ROOT/partials/aws-bedrock-agent-runtime-sink-description.adoc
@@ -38,3 +38,60 @@ The step that sends to the Kamelet, in a route:
       proxyPort: 3128
       proxyProtocol: "HTTP"
 ----
+
+=== Operations
+
+`operation` chooses what the Kamelet does with the question in the body:
+
+[width="100%",cols="1,3,2",options="header"]
+|===
+| `operation` | What it does | Options it needs
+| `retrieveAndGenerate` (default)
+| Finds the passages that match the question in the knowledge base, and has 
the model write the answer from them. The
+  body afterwards is the answer, as text.
+| `modelId`, `knowledgeBaseId`
+| `retrieve`
+| Only finds the passages, without an answer. The body afterwards is a List of 
the passages, each with its text
+  (`content.text`), its `score` and the `location` of its document. 
`numberOfResults` limits how many, and `searchType`
+  chooses between a `SEMANTIC` and a `HYBRID` search.
+| `knowledgeBaseId`
+| `invokeAgent`
+| Sends the question to a Bedrock agent, which answers it with its own 
instructions, knowledge bases and actions. The
+  body afterwards is the answer, as text.
+| `agentId`, `agentAliasId`
+|===
+
+The passages from `retrieve` are objects of the AWS SDK for Java, not JSON: 
turned into JSON as they are, each is an
+empty object. Take the parts you need in the next step. For example, to keep 
the text of the first passage:
+
+[source,yaml,subs='+attributes,macros']
+----
+- to:
+    uri: "kamelet:aws-bedrock-agent-runtime-sink"
+    parameters:
+      operation: "retrieve"
+      knowledgeBaseId: "AB12CD34EF"
+      numberOfResults: 3
+      searchType: "HYBRID"
+      region: "us-east-1"
+      useDefaultCredentialsProvider: true
+- setBody:
+    simple: "$\{body[0].content.text}"
+----
+
+To ask an agent, and continue the conversation with the session ID of the 
answer:
+
+[source,yaml,subs='+attributes,macros']
+----
+- to:
+    uri: "kamelet:aws-bedrock-agent-runtime-sink"
+    parameters:
+      operation: "invokeAgent"
+      agentId: "KX7Q2M9WZB"
+      agentAliasId: "TSTALIASID"
+      region: "us-east-1"
+      useDefaultCredentialsProvider: true
+----
+
+Without the `CamelAwsBedrockAgentRuntimeSessionId` header, each message starts 
a new session, and the header holds
+its ID afterwards. Send that ID in the header with the next question to 
continue the same conversation.
diff --git a/docs/modules/ROOT/partials/aws-redshift-sink-description.adoc 
b/docs/modules/ROOT/partials/aws-redshift-sink-description.adoc
index 8f43376db..41ae3b9a9 100644
--- a/docs/modules/ROOT/partials/aws-redshift-sink-description.adoc
+++ b/docs/modules/ROOT/partials/aws-redshift-sink-description.adoc
@@ -19,3 +19,19 @@ Here is example input for the example query:
 ----
 { "username":"oscerd", "city":"Rome"}
 ----
+
+=== Connection Pool
+
+The Kamelet keeps a pool of connections to the database:
+
+* `maxTotal`: the most connections it opens at the same time, 8 when not set.
+* `maxIdle`: the most unused connections it keeps open, 8 when not set.
+* `maxWaitMillis`: how long a message waits for a free connection when 
`maxTotal` are in use, in milliseconds, before
+  it fails. When not set, it waits as long as it takes.
+
+[source,yaml,subs='+attributes,macros']
+----
+maxTotal: 4
+maxIdle: 2
+maxWaitMillis: 5000
+----
diff --git a/docs/modules/ROOT/partials/aws-redshift-source-description.adoc 
b/docs/modules/ROOT/partials/aws-redshift-source-description.adoc
index 3a5cae967..f6e4f4d14 100644
--- a/docs/modules/ROOT/partials/aws-redshift-source-description.adoc
+++ b/docs/modules/ROOT/partials/aws-redshift-source-description.adoc
@@ -3,3 +3,23 @@
 === Authentication
 
 This Kamelet logs in to the Redshift database with a database user and 
password (`username` and `password`), not with AWS access keys. It connects 
with the Amazon Redshift JDBC driver, which uses TLS by default.
+
+=== Connection Pool
+
+The Kamelet keeps a pool of connections to the database:
+
+* `maxTotal`: the most connections it opens at the same time, 8 when not set.
+* `maxIdle`: the most unused connections it keeps open, 8 when not set.
+* `maxWaitMillis`: how long a message waits for a free connection when 
`maxTotal` are in use, in milliseconds, before
+  it fails. When not set, it waits as long as it takes.
+
+While it sends the rows of a poll, the source keeps one connection, and 
`consumedQuery` needs a second one. Do not set
+`maxTotal` to 1 when you use it: `consumedQuery` then waits for a connection 
for ever, or gives up after
+`maxWaitMillis`, and the row is not marked.
+
+[source,yaml,subs='+attributes,macros']
+----
+maxTotal: 4
+maxIdle: 2
+maxWaitMillis: 5000
+----
diff --git a/kamelets/aws-bedrock-agent-runtime-sink.kamelet.yaml 
b/kamelets/aws-bedrock-agent-runtime-sink.kamelet.yaml
index 04f1f845f..2932b402e 100644
--- a/kamelets/aws-bedrock-agent-runtime-sink.kamelet.yaml
+++ b/kamelets/aws-bedrock-agent-runtime-sink.kamelet.yaml
@@ -32,31 +32,57 @@ spec:
   definition:
     title: "AWS Bedrock Agent Runtime Sink"
     description: |-
-      Answers the question in each message from the documents of an Amazon 
Bedrock knowledge base, with a model that writes the answer from the passages 
it finds.
+      Answers the question in each message from the documents of an Amazon 
Bedrock knowledge base, or finds the passages of the documents that match it, 
or passes it to a Bedrock agent.
 
-      Use it to build a question-and-answer service or a chatbot over your own 
documents, such as manuals, policies or FAQs, loaded into a Bedrock knowledge 
base. To load new documents into the knowledge base, use 
`aws-bedrock-agent-sink`; to call a model without a knowledge base, use 
`aws-bedrock-text-sink`.
+      Use it to build a question-and-answer service or a chatbot over your own 
documents, such as manuals, policies or FAQs, loaded into a Bedrock knowledge 
base. Set `operation` to `retrieve` to get only the passages that match the 
question, for example to show them as search results or to give them to a model 
of your own. Set it to `invokeAgent` to ask a Bedrock agent that you have set 
up in the Bedrock console. To load new documents into the knowledge base, use 
`aws-bedrock-agent-sink [...]
 
-      Input: the body is the question, as text. The optional 
`CamelAwsBedrockAgentRuntimeSessionId` header continues an earlier 
conversation: set it to the session ID of an earlier answer.
+      Input: the body is the question, as text. The optional 
`CamelAwsBedrockAgentRuntimeSessionId` header continues an earlier 
conversation, with `retrieveAndGenerate` and `invokeAgent`: set it to the 
session ID of an earlier answer.
 
-      Output: when it is used inside a route, the body afterwards is the 
answer, as text. The `CamelAwsBedrockAgentRuntimeSessionId` header holds the ID 
of the session, and the `CamelAwsBedrockAgentRuntimeCitations` header the 
passages of the documents the answer is based on, as objects of the AWS SDK for 
Java.
+      Output: when it is used inside a route, the body afterwards depends on 
`operation`. With `retrieveAndGenerate`, the default, and with `invokeAgent`, 
it is the answer, as text. The `CamelAwsBedrockAgentRuntimeSessionId` header 
holds the ID of the session, and the `CamelAwsBedrockAgentRuntimeCitations` 
header the passages of the documents the answer is based on, as objects of the 
AWS SDK for Java. With `retrieve`, the body is a List of the passages found, 
each an object of the AWS SD [...]
 
-      Good to know: to reach AWS through an HTTP proxy, set `proxyHost` and 
`proxyPort`, and set `proxyProtocol` to `HTTP` for a proxy that takes plain 
HTTP, such as Squid.
+      Good to know: `retrieveAndGenerate` needs `modelId` and 
`knowledgeBaseId`, `retrieve` needs `knowledgeBaseId`, and `invokeAgent` needs 
`agentId` and `agentAliasId`; without them, `retrieve` and `invokeAgent` fail 
before they call Bedrock. The passages from `retrieve` are not JSON, and turned 
into JSON as they are, each is an empty object: take the parts you need in the 
next step, such as `$\{body[0].content.text}` in a Simple expression. With 
`invokeAgent` and no session ID, each m [...]
     required:
-      - modelId
-      - knowledgeBaseId
       - region
     type: object
     properties:
       modelId:
         title: Model ID
-        description: The ID of the Bedrock model that writes the answers from 
the parts of the documents that were found. It must be available in the region 
of the knowledge base.
+        description: The ID of the Bedrock model that writes the answers from 
the parts of the documents that were found. It must be available in the region 
of the knowledge base. Required when `operation` is `retrieveAndGenerate`; the 
other operations do not use it.
         type: string
         enum: ["anthropic.claude-instant-v1", "anthropic.claude-v2", 
"anthropic.claude-v2:1", "anthropic.claude-3-sonnet-20240229-v1:0"]
       knowledgeBaseId:
         title: Knowledge Base ID
-        description: The ID of the knowledge base to search, a code of 10 
letters and digits shown in the Bedrock console.
+        description: The ID of the knowledge base to search, a code of 10 
letters and digits shown in the Bedrock console. Required when `operation` is 
`retrieveAndGenerate` or `retrieve`; `invokeAgent` does not use it, as the 
agent has its own knowledge bases.
         type: string
         example: AB12CD34EF
+      operation:
+        title: Operation
+        description: "What to do with the question. `retrieveAndGenerate` 
finds the passages that match it in the knowledge base, and has the model in 
`modelId` write the answer from them. `retrieve` only finds the passages, and 
gives them without an answer. `invokeAgent` sends the question to the Bedrock 
agent in `agentId`, which answers it in its own way, for example with its own 
knowledge bases and actions."
+        type: string
+        enum: ["retrieveAndGenerate", "retrieve", "invokeAgent"]
+        default: retrieveAndGenerate
+      agentId:
+        title: Agent ID
+        description: The ID of the Bedrock agent to ask, a code of 10 letters 
and digits shown in the Bedrock console. Required when `operation` is 
`invokeAgent`; the other operations do not use it.
+        type: string
+        pattern: "^[0-9A-Za-z]{10}$"
+        example: KX7Q2M9WZB
+      agentAliasId:
+        title: Agent Alias ID
+        description: The ID of the alias of the agent in `agentId`, a code of 
10 letters and digits shown in the Bedrock console. An alias points to one 
version of the agent; `TSTALIASID` is the alias of its working draft. Required 
when `operation` is `invokeAgent`.
+        type: string
+        pattern: "^[0-9A-Za-z]{10}$"
+        example: TSTALIASID
+      numberOfResults:
+        title: Number of Results
+        description: The most passages to give for each question. Only used 
when `operation` is `retrieve`. When it is not set, Bedrock decides how many.
+        type: integer
+        example: 10
+      searchType:
+        title: Search Type
+        description: "How to search the knowledge base for the passages: 
`SEMANTIC` looks for passages with the same meaning as the question, `HYBRID` 
also looks for the words of the question, which helps for names and codes. Only 
used when `operation` is `retrieve`. When it is not set, Bedrock decides."
+        type: string
+        enum: ["HYBRID", "SEMANTIC"]
       accessKey:
         title: Access Key
         description: "The access key ID of an IAM user, which AWS gives when 
you create an access key for the user (in the AWS console: IAM, Users, Security 
credentials). Use it together with `secretKey`, or leave both empty and set 
`useDefaultCredentialsProvider` or `useProfileCredentialsProvider` instead."
@@ -145,7 +171,11 @@ spec:
           type: string
         CamelAwsBedrockAgentRuntimeCitations:
           title: Citations
-          description: The passages of the documents the answer is based on, 
as a List of objects of the AWS SDK for Java.
+          description: The passages of the documents the answer is based on, 
as a List of objects of the AWS SDK for Java. Set by `retrieveAndGenerate` and 
`invokeAgent`.
+          type: array
+        CamelAwsBedrockAgentRuntimeRetrievedResults:
+          title: Retrieved Results
+          description: The passages that `retrieve` found, as a List of 
objects of the AWS SDK for Java, the same as the body.
           type: array
   dependencies:
     - "camel:aws-bedrock"
@@ -154,14 +184,36 @@ spec:
     from:
       uri: kamelet:source
       steps:
+        - choice:
+            when:
+              - expression:
+                  simple:
+                    expression: "'{{?numberOfResults}}' != ''"
+                steps:
+                  - setHeader:
+                      name: CamelAwsBedrockAgentRuntimeNumberOfResults
+                      expression:
+                        constant:
+                          expression: "{{?numberOfResults}}"
+        - choice:
+            when:
+              - expression:
+                  simple:
+                    expression: "'{{?searchType}}' != ''"
+                steps:
+                  - setHeader:
+                      name: CamelAwsBedrockAgentRuntimeSearchType
+                      expression:
+                        constant:
+                          expression: "{{?searchType}}"
         - to:
             uri: aws-bedrock-agent-runtime
             parameters:
               label: bedrock-knowledge
               accessKey: "RAW({{?accessKey}})"
-              knowledgeBaseId: "{{knowledgeBaseId}}"
-              modelId: "{{modelId}}"
-              operation: retrieveAndGenerate
+              knowledgeBaseId: "{{?knowledgeBaseId}}"
+              modelId: "{{?modelId}}"
+              operation: "{{operation}}"
               overrideEndpoint: "{{overrideEndpoint}}"
               profileCredentialsName: "{{?profileCredentialsName}}"
               region: "{{region}}"
@@ -174,3 +226,5 @@ spec:
               proxyHost: "{{?proxyHost}}"
               proxyPort: "{{?proxyPort}}"
               proxyProtocol: "{{?proxyProtocol}}"
+              agentId: "{{?agentId}}"
+              agentAliasId: "{{?agentAliasId}}"
diff --git a/kamelets/aws-redshift-sink.kamelet.yaml 
b/kamelets/aws-redshift-sink.kamelet.yaml
index c0af5dab8..cfe75bc2a 100644
--- a/kamelets/aws-redshift-sink.kamelet.yaml
+++ b/kamelets/aws-redshift-sink.kamelet.yaml
@@ -86,6 +86,21 @@ spec:
         description: "Extra settings for the Amazon Redshift JDBC driver, as 
`name=value` pairs separated by `;`, such as `loginTimeout=30`. When it is not 
set, the driver connects with TLS, as it does by default. The value is not 
hidden like a password, and it can show in the log when the integration starts, 
so do not put a password in it."
         type: string
         example: loginTimeout=30
+      maxTotal:
+        title: Max Connections
+        description: The most connections to the database that the Kamelet 
opens at the same time. When all of them are in use, the next message waits for 
one to be free, as long as `maxWaitMillis` allows. When it is not set, the 
limit is 8.
+        type: integer
+        example: 20
+      maxIdle:
+        title: Max Idle Connections
+        description: The most unused connections to keep open for later. A 
connection that is given back when this many are unused already is closed. When 
it is not set, up to 8 are kept open.
+        type: integer
+        example: 2
+      maxWaitMillis:
+        title: Max Wait
+        description: How long to wait for a free connection when `maxTotal` 
connections are in use, in milliseconds. After that, the message fails. When it 
is not set, it waits as long as it takes.
+        type: integer
+        example: 5000
   types:
     in:
       mediaType: application/json
@@ -116,6 +131,9 @@ spec:
           url: "jdbc:redshift://{{serverName}}:{{serverPort}}/{{databaseName}}"
           driverClassName: com.amazon.redshift.jdbc.Driver
           connectionProperties: "{{?connectionProperties}}"
+          maxTotal: "{{?maxTotal}}"
+          maxIdle: "{{?maxIdle}}"
+          maxWaitMillis: "{{?maxWaitMillis}}"
     from:
       uri: kamelet:source
       steps:
diff --git a/kamelets/aws-redshift-source.kamelet.yaml 
b/kamelets/aws-redshift-source.kamelet.yaml
index 6ce8d1263..72f625b74 100644
--- a/kamelets/aws-redshift-source.kamelet.yaml
+++ b/kamelets/aws-redshift-source.kamelet.yaml
@@ -94,6 +94,21 @@ spec:
         description: "Extra settings for the Amazon Redshift JDBC driver, as 
`name=value` pairs separated by `;`, such as `loginTimeout=30`. When it is not 
set, the driver connects with TLS, as it does by default. The value is not 
hidden like a password, and it can show in the log when the integration starts, 
so do not put a password in it."
         type: string
         example: loginTimeout=30
+      maxTotal:
+        title: Max Connections
+        description: The most connections to the database that the Kamelet 
opens at the same time. While it sends the rows of a poll, the Kamelet keeps 
one connection, and `consumedQuery` needs a second one, so do not set it to 1 
when you use it. When all of them are in use, the next message waits for one to 
be free, as long as `maxWaitMillis` allows. When it is not set, the limit is 8.
+        type: integer
+        example: 20
+      maxIdle:
+        title: Max Idle Connections
+        description: The most unused connections to keep open for later. A 
connection that is given back when this many are unused already is closed. When 
it is not set, up to 8 are kept open.
+        type: integer
+        example: 2
+      maxWaitMillis:
+        title: Max Wait
+        description: How long to wait for a free connection when `maxTotal` 
connections are in use, in milliseconds. After that, the message fails. When it 
is not set, it waits as long as it takes.
+        type: integer
+        example: 5000
   types:
     out:
       mediaType: application/json
@@ -117,6 +132,9 @@ spec:
           url: "jdbc:redshift://{{serverName}}:{{serverPort}}/{{databaseName}}"
           driverClassName: com.amazon.redshift.jdbc.Driver
           connectionProperties: "{{?connectionProperties}}"
+          maxTotal: "{{?maxTotal}}"
+          maxIdle: "{{?maxIdle}}"
+          maxWaitMillis: "{{?maxWaitMillis}}"
     from:
       uri: 
"{{local-sql-redshift-source}}:{{query}}?dataSource=#bean:{{dsBean}}&onConsume=RAW({{?consumedQuery}})&delay={{delay}}"
       steps:
diff --git 
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json 
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index 0e3c9aa67..1c14d4648 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -24,8 +24,8 @@
     "type" : "sink",
     "supportLevel" : "Stable",
     "title" : "AWS Bedrock Agent Runtime Sink",
-    "summary" : "Answers the question in each message from the documents of an 
Amazon Bedrock knowledge base, with a model that writes the answer from the 
passages it finds.",
-    "description" : "Answers the question in each message from the documents 
of an Amazon Bedrock knowledge base, with a model that writes the answer from 
the passages it finds.\n\nUse it to build a question-and-answer service or a 
chatbot over your own documents, such as manuals, policies or FAQs, loaded into 
a Bedrock knowledge base. To load new documents into the knowledge base, use 
`aws-bedrock-agent-sink`; to call a model without a knowledge base, use 
`aws-bedrock-text-sink`.\n\nInp [...]
+    "summary" : "Answers the question in each message from the documents of an 
Amazon Bedrock knowledge base, or finds the passages of the documents that 
match it, or passes it to a Bedrock agent.",
+    "description" : "Answers the question in each message from the documents 
of an Amazon Bedrock knowledge base, or finds the passages of the documents 
that match it, or passes it to a Bedrock agent.\n\nUse it to build a 
question-and-answer service or a chatbot over your own documents, such as 
manuals, policies or FAQs, loaded into a Bedrock knowledge base. Set 
`operation` to `retrieve` to get only the passages that match the question, for 
example to show them as search results or to gi [...]
     "group" : "AWS Bedrock",
     "namespace" : "AWS",
     "provider" : "Apache Software Foundation"
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/aws-bedrock-agent-runtime-sink.kamelet.yaml
 
b/library/camel-kamelets/src/main/resources/kamelets/aws-bedrock-agent-runtime-sink.kamelet.yaml
index 04f1f845f..2932b402e 100644
--- 
a/library/camel-kamelets/src/main/resources/kamelets/aws-bedrock-agent-runtime-sink.kamelet.yaml
+++ 
b/library/camel-kamelets/src/main/resources/kamelets/aws-bedrock-agent-runtime-sink.kamelet.yaml
@@ -32,31 +32,57 @@ spec:
   definition:
     title: "AWS Bedrock Agent Runtime Sink"
     description: |-
-      Answers the question in each message from the documents of an Amazon 
Bedrock knowledge base, with a model that writes the answer from the passages 
it finds.
+      Answers the question in each message from the documents of an Amazon 
Bedrock knowledge base, or finds the passages of the documents that match it, 
or passes it to a Bedrock agent.
 
-      Use it to build a question-and-answer service or a chatbot over your own 
documents, such as manuals, policies or FAQs, loaded into a Bedrock knowledge 
base. To load new documents into the knowledge base, use 
`aws-bedrock-agent-sink`; to call a model without a knowledge base, use 
`aws-bedrock-text-sink`.
+      Use it to build a question-and-answer service or a chatbot over your own 
documents, such as manuals, policies or FAQs, loaded into a Bedrock knowledge 
base. Set `operation` to `retrieve` to get only the passages that match the 
question, for example to show them as search results or to give them to a model 
of your own. Set it to `invokeAgent` to ask a Bedrock agent that you have set 
up in the Bedrock console. To load new documents into the knowledge base, use 
`aws-bedrock-agent-sink [...]
 
-      Input: the body is the question, as text. The optional 
`CamelAwsBedrockAgentRuntimeSessionId` header continues an earlier 
conversation: set it to the session ID of an earlier answer.
+      Input: the body is the question, as text. The optional 
`CamelAwsBedrockAgentRuntimeSessionId` header continues an earlier 
conversation, with `retrieveAndGenerate` and `invokeAgent`: set it to the 
session ID of an earlier answer.
 
-      Output: when it is used inside a route, the body afterwards is the 
answer, as text. The `CamelAwsBedrockAgentRuntimeSessionId` header holds the ID 
of the session, and the `CamelAwsBedrockAgentRuntimeCitations` header the 
passages of the documents the answer is based on, as objects of the AWS SDK for 
Java.
+      Output: when it is used inside a route, the body afterwards depends on 
`operation`. With `retrieveAndGenerate`, the default, and with `invokeAgent`, 
it is the answer, as text. The `CamelAwsBedrockAgentRuntimeSessionId` header 
holds the ID of the session, and the `CamelAwsBedrockAgentRuntimeCitations` 
header the passages of the documents the answer is based on, as objects of the 
AWS SDK for Java. With `retrieve`, the body is a List of the passages found, 
each an object of the AWS SD [...]
 
-      Good to know: to reach AWS through an HTTP proxy, set `proxyHost` and 
`proxyPort`, and set `proxyProtocol` to `HTTP` for a proxy that takes plain 
HTTP, such as Squid.
+      Good to know: `retrieveAndGenerate` needs `modelId` and 
`knowledgeBaseId`, `retrieve` needs `knowledgeBaseId`, and `invokeAgent` needs 
`agentId` and `agentAliasId`; without them, `retrieve` and `invokeAgent` fail 
before they call Bedrock. The passages from `retrieve` are not JSON, and turned 
into JSON as they are, each is an empty object: take the parts you need in the 
next step, such as `$\{body[0].content.text}` in a Simple expression. With 
`invokeAgent` and no session ID, each m [...]
     required:
-      - modelId
-      - knowledgeBaseId
       - region
     type: object
     properties:
       modelId:
         title: Model ID
-        description: The ID of the Bedrock model that writes the answers from 
the parts of the documents that were found. It must be available in the region 
of the knowledge base.
+        description: The ID of the Bedrock model that writes the answers from 
the parts of the documents that were found. It must be available in the region 
of the knowledge base. Required when `operation` is `retrieveAndGenerate`; the 
other operations do not use it.
         type: string
         enum: ["anthropic.claude-instant-v1", "anthropic.claude-v2", 
"anthropic.claude-v2:1", "anthropic.claude-3-sonnet-20240229-v1:0"]
       knowledgeBaseId:
         title: Knowledge Base ID
-        description: The ID of the knowledge base to search, a code of 10 
letters and digits shown in the Bedrock console.
+        description: The ID of the knowledge base to search, a code of 10 
letters and digits shown in the Bedrock console. Required when `operation` is 
`retrieveAndGenerate` or `retrieve`; `invokeAgent` does not use it, as the 
agent has its own knowledge bases.
         type: string
         example: AB12CD34EF
+      operation:
+        title: Operation
+        description: "What to do with the question. `retrieveAndGenerate` 
finds the passages that match it in the knowledge base, and has the model in 
`modelId` write the answer from them. `retrieve` only finds the passages, and 
gives them without an answer. `invokeAgent` sends the question to the Bedrock 
agent in `agentId`, which answers it in its own way, for example with its own 
knowledge bases and actions."
+        type: string
+        enum: ["retrieveAndGenerate", "retrieve", "invokeAgent"]
+        default: retrieveAndGenerate
+      agentId:
+        title: Agent ID
+        description: The ID of the Bedrock agent to ask, a code of 10 letters 
and digits shown in the Bedrock console. Required when `operation` is 
`invokeAgent`; the other operations do not use it.
+        type: string
+        pattern: "^[0-9A-Za-z]{10}$"
+        example: KX7Q2M9WZB
+      agentAliasId:
+        title: Agent Alias ID
+        description: The ID of the alias of the agent in `agentId`, a code of 
10 letters and digits shown in the Bedrock console. An alias points to one 
version of the agent; `TSTALIASID` is the alias of its working draft. Required 
when `operation` is `invokeAgent`.
+        type: string
+        pattern: "^[0-9A-Za-z]{10}$"
+        example: TSTALIASID
+      numberOfResults:
+        title: Number of Results
+        description: The most passages to give for each question. Only used 
when `operation` is `retrieve`. When it is not set, Bedrock decides how many.
+        type: integer
+        example: 10
+      searchType:
+        title: Search Type
+        description: "How to search the knowledge base for the passages: 
`SEMANTIC` looks for passages with the same meaning as the question, `HYBRID` 
also looks for the words of the question, which helps for names and codes. Only 
used when `operation` is `retrieve`. When it is not set, Bedrock decides."
+        type: string
+        enum: ["HYBRID", "SEMANTIC"]
       accessKey:
         title: Access Key
         description: "The access key ID of an IAM user, which AWS gives when 
you create an access key for the user (in the AWS console: IAM, Users, Security 
credentials). Use it together with `secretKey`, or leave both empty and set 
`useDefaultCredentialsProvider` or `useProfileCredentialsProvider` instead."
@@ -145,7 +171,11 @@ spec:
           type: string
         CamelAwsBedrockAgentRuntimeCitations:
           title: Citations
-          description: The passages of the documents the answer is based on, 
as a List of objects of the AWS SDK for Java.
+          description: The passages of the documents the answer is based on, 
as a List of objects of the AWS SDK for Java. Set by `retrieveAndGenerate` and 
`invokeAgent`.
+          type: array
+        CamelAwsBedrockAgentRuntimeRetrievedResults:
+          title: Retrieved Results
+          description: The passages that `retrieve` found, as a List of 
objects of the AWS SDK for Java, the same as the body.
           type: array
   dependencies:
     - "camel:aws-bedrock"
@@ -154,14 +184,36 @@ spec:
     from:
       uri: kamelet:source
       steps:
+        - choice:
+            when:
+              - expression:
+                  simple:
+                    expression: "'{{?numberOfResults}}' != ''"
+                steps:
+                  - setHeader:
+                      name: CamelAwsBedrockAgentRuntimeNumberOfResults
+                      expression:
+                        constant:
+                          expression: "{{?numberOfResults}}"
+        - choice:
+            when:
+              - expression:
+                  simple:
+                    expression: "'{{?searchType}}' != ''"
+                steps:
+                  - setHeader:
+                      name: CamelAwsBedrockAgentRuntimeSearchType
+                      expression:
+                        constant:
+                          expression: "{{?searchType}}"
         - to:
             uri: aws-bedrock-agent-runtime
             parameters:
               label: bedrock-knowledge
               accessKey: "RAW({{?accessKey}})"
-              knowledgeBaseId: "{{knowledgeBaseId}}"
-              modelId: "{{modelId}}"
-              operation: retrieveAndGenerate
+              knowledgeBaseId: "{{?knowledgeBaseId}}"
+              modelId: "{{?modelId}}"
+              operation: "{{operation}}"
               overrideEndpoint: "{{overrideEndpoint}}"
               profileCredentialsName: "{{?profileCredentialsName}}"
               region: "{{region}}"
@@ -174,3 +226,5 @@ spec:
               proxyHost: "{{?proxyHost}}"
               proxyPort: "{{?proxyPort}}"
               proxyProtocol: "{{?proxyProtocol}}"
+              agentId: "{{?agentId}}"
+              agentAliasId: "{{?agentAliasId}}"
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/aws-redshift-sink.kamelet.yaml
 
b/library/camel-kamelets/src/main/resources/kamelets/aws-redshift-sink.kamelet.yaml
index c0af5dab8..cfe75bc2a 100644
--- 
a/library/camel-kamelets/src/main/resources/kamelets/aws-redshift-sink.kamelet.yaml
+++ 
b/library/camel-kamelets/src/main/resources/kamelets/aws-redshift-sink.kamelet.yaml
@@ -86,6 +86,21 @@ spec:
         description: "Extra settings for the Amazon Redshift JDBC driver, as 
`name=value` pairs separated by `;`, such as `loginTimeout=30`. When it is not 
set, the driver connects with TLS, as it does by default. The value is not 
hidden like a password, and it can show in the log when the integration starts, 
so do not put a password in it."
         type: string
         example: loginTimeout=30
+      maxTotal:
+        title: Max Connections
+        description: The most connections to the database that the Kamelet 
opens at the same time. When all of them are in use, the next message waits for 
one to be free, as long as `maxWaitMillis` allows. When it is not set, the 
limit is 8.
+        type: integer
+        example: 20
+      maxIdle:
+        title: Max Idle Connections
+        description: The most unused connections to keep open for later. A 
connection that is given back when this many are unused already is closed. When 
it is not set, up to 8 are kept open.
+        type: integer
+        example: 2
+      maxWaitMillis:
+        title: Max Wait
+        description: How long to wait for a free connection when `maxTotal` 
connections are in use, in milliseconds. After that, the message fails. When it 
is not set, it waits as long as it takes.
+        type: integer
+        example: 5000
   types:
     in:
       mediaType: application/json
@@ -116,6 +131,9 @@ spec:
           url: "jdbc:redshift://{{serverName}}:{{serverPort}}/{{databaseName}}"
           driverClassName: com.amazon.redshift.jdbc.Driver
           connectionProperties: "{{?connectionProperties}}"
+          maxTotal: "{{?maxTotal}}"
+          maxIdle: "{{?maxIdle}}"
+          maxWaitMillis: "{{?maxWaitMillis}}"
     from:
       uri: kamelet:source
       steps:
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/aws-redshift-source.kamelet.yaml
 
b/library/camel-kamelets/src/main/resources/kamelets/aws-redshift-source.kamelet.yaml
index 6ce8d1263..72f625b74 100644
--- 
a/library/camel-kamelets/src/main/resources/kamelets/aws-redshift-source.kamelet.yaml
+++ 
b/library/camel-kamelets/src/main/resources/kamelets/aws-redshift-source.kamelet.yaml
@@ -94,6 +94,21 @@ spec:
         description: "Extra settings for the Amazon Redshift JDBC driver, as 
`name=value` pairs separated by `;`, such as `loginTimeout=30`. When it is not 
set, the driver connects with TLS, as it does by default. The value is not 
hidden like a password, and it can show in the log when the integration starts, 
so do not put a password in it."
         type: string
         example: loginTimeout=30
+      maxTotal:
+        title: Max Connections
+        description: The most connections to the database that the Kamelet 
opens at the same time. While it sends the rows of a poll, the Kamelet keeps 
one connection, and `consumedQuery` needs a second one, so do not set it to 1 
when you use it. When all of them are in use, the next message waits for one to 
be free, as long as `maxWaitMillis` allows. When it is not set, the limit is 8.
+        type: integer
+        example: 20
+      maxIdle:
+        title: Max Idle Connections
+        description: The most unused connections to keep open for later. A 
connection that is given back when this many are unused already is closed. When 
it is not set, up to 8 are kept open.
+        type: integer
+        example: 2
+      maxWaitMillis:
+        title: Max Wait
+        description: How long to wait for a free connection when `maxTotal` 
connections are in use, in milliseconds. After that, the message fails. When it 
is not set, it waits as long as it takes.
+        type: integer
+        example: 5000
   types:
     out:
       mediaType: application/json
@@ -117,6 +132,9 @@ spec:
           url: "jdbc:redshift://{{serverName}}:{{serverPort}}/{{databaseName}}"
           driverClassName: com.amazon.redshift.jdbc.Driver
           connectionProperties: "{{?connectionProperties}}"
+          maxTotal: "{{?maxTotal}}"
+          maxIdle: "{{?maxIdle}}"
+          maxWaitMillis: "{{?maxWaitMillis}}"
     from:
       uri: 
"{{local-sql-redshift-source}}:{{query}}?dataSource=#bean:{{dsBean}}&onConsume=RAW({{?consumedQuery}})&delay={{delay}}"
       steps:

Reply via email to