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 9ce3da96e756 CAMEL-28038: camel-aws2-lambda - listEventSourceMapping
reads the marker and the page size (#31264)
9ce3da96e756 is described below
commit 9ce3da96e756705f70afb9b5552496b5df8d5451
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed Dec 2 21:37:22 2026 +0100
CAMEL-28038: camel-aws2-lambda - listEventSourceMapping reads the marker
and the page size (#31264)
listEventSourceMapping built its request with the function name only, so
the answer was truncated at the service
default and a route had no way to reach the next page. Its three paginated
siblings, listFunctions, listVersions
and listAliases, all read CamelAwsLambdaMarker and CamelAwsLambdaMaxItems
into the builder and set the marker and
CamelAwsLambdaIsTruncated on the out message. Do the same here. (listTags
is not paginated by the service.)
The two headers were already labelled for listEventSourceMapping in
Lambda2Constants, so the component documented
a pagination it did not implement. The description of CamelAwsLambdaMarker
now names the operation as well.
AmazonLambdaClientMock returned a single mapping and ignored the request,
so no test could cover paging. It now
pages over three mappings with the marker and maxItems, like the service
does; entry 0 is unchanged, so the
existing assertion still holds.
Co-Authored-By: Claude Opus 5 <[email protected]>
---
.../camel/catalog/components/aws2-lambda.json | 2 +-
.../camel/component/aws2/lambda/aws2-lambda.json | 2 +-
.../component/aws2/lambda/Lambda2Constants.java | 5 ++--
.../component/aws2/lambda/Lambda2Producer.java | 10 ++++++++
.../aws2/lambda/AmazonLambdaClientMock.java | 26 ++++++++++++++++-----
.../component/aws2/lambda/LambdaProducerTest.java | 27 ++++++++++++++++++++++
.../dsl/Lambda2EndpointBuilderFactory.java | 5 ++--
7 files changed, 65 insertions(+), 12 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-lambda.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-lambda.json
index b65902a2f9d2..0a8244f170ea 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-lambda.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-lambda.json
@@ -80,7 +80,7 @@
"CamelAwsLambdaFunctionVersion": { "index": 27, "kind": "header",
"displayName": "", "group": "createAlias listAliases", "label": "createAlias
listAliases", "required": false, "javaType": "String", "deprecated": false,
"autowired": false, "secret": false, "description": "For createAlias, the
function version that the alias points to, which is required. For listAliases,
only the aliases that point to this version are listed.", "constantName":
"org.apache.camel.component.aws2.lambda.La [...]
"CamelAwsLambdaAliasFunctionName": { "index": 28, "kind": "header",
"displayName": "", "group": "createAlias deleteAlias getAlias", "label":
"createAlias deleteAlias getAlias", "required": true, "javaType": "String",
"deprecated": false, "autowired": false, "secret": false, "description": "The
name of the alias. Required.", "constantName":
"org.apache.camel.component.aws2.lambda.Lambda2Constants#FUNCTION_ALIAS_NAME" },
"CamelAwsLambdaAliasFunctionDescription": { "index": 29, "kind": "header",
"displayName": "", "group": "createAlias", "label": "createAlias", "required":
false, "javaType": "String", "deprecated": false, "autowired": false, "secret":
false, "description": "The description of the alias.", "constantName":
"org.apache.camel.component.aws2.lambda.Lambda2Constants#FUNCTION_ALIAS_DESCRIPTION"
},
- "CamelAwsLambdaMarker": { "index": 30, "kind": "header", "displayName":
"", "group": "listFunctions listVersions listAliases listEventSourceMapping
listTags", "label": "listFunctions listVersions listAliases
listEventSourceMapping listTags", "required": false, "javaType": "String",
"deprecated": false, "autowired": false, "secret": false, "description": "The
pagination token. Set it to the value of this header that a previous list
returned, to get the next page. listFunctions, listVe [...]
+ "CamelAwsLambdaMarker": { "index": 30, "kind": "header", "displayName":
"", "group": "listFunctions listVersions listAliases listEventSourceMapping
listTags", "label": "listFunctions listVersions listAliases
listEventSourceMapping listTags", "required": false, "javaType": "String",
"deprecated": false, "autowired": false, "secret": false, "description": "The
pagination token. Set it to the value of this header that a previous list
returned, to get the next page. listFunctions, listVe [...]
"CamelAwsLambdaMaxItems": { "index": 31, "kind": "header", "displayName":
"", "group": "listFunctions listVersions listAliases listEventSourceMapping",
"label": "listFunctions listVersions listAliases listEventSourceMapping",
"required": false, "javaType": "Integer", "deprecated": false, "autowired":
false, "secret": false, "description": "The maximum number of items to return.
listFunctions, listVersions and listFunctionUrlConfigs return at most 50 items
per call, even if this value [...]
"CamelAwsLambdaIsTruncated": { "index": 32, "kind": "header",
"displayName": "", "group": "listFunctions listVersions listAliases
listEventSourceMapping", "label": "listFunctions listVersions listAliases
listEventSourceMapping", "required": false, "javaType": "Boolean",
"deprecated": false, "autowired": false, "secret": false, "description":
"Whether more results are available: true when the response has the token of a
next page in CamelAwsLambdaMarker.", "constantName": "org.apache. [...]
"CamelAwsLambdaFunctionArn": { "index": 33, "kind": "header",
"displayName": "", "group": "createFunction getFunction publishVersion
createAlias getAlias", "label": "createFunction getFunction publishVersion
createAlias getAlias", "required": false, "javaType": "String", "deprecated":
false, "autowired": false, "secret": false, "description": "The ARN of the
function, set by createFunction, getFunctionConfiguration,
updateFunctionConfiguration, createFunctionUrlConfig, getFunctionUrl [...]
diff --git
a/components/camel-aws/camel-aws2-lambda/src/generated/resources/META-INF/org/apache/camel/component/aws2/lambda/aws2-lambda.json
b/components/camel-aws/camel-aws2-lambda/src/generated/resources/META-INF/org/apache/camel/component/aws2/lambda/aws2-lambda.json
index b65902a2f9d2..0a8244f170ea 100644
---
a/components/camel-aws/camel-aws2-lambda/src/generated/resources/META-INF/org/apache/camel/component/aws2/lambda/aws2-lambda.json
+++
b/components/camel-aws/camel-aws2-lambda/src/generated/resources/META-INF/org/apache/camel/component/aws2/lambda/aws2-lambda.json
@@ -80,7 +80,7 @@
"CamelAwsLambdaFunctionVersion": { "index": 27, "kind": "header",
"displayName": "", "group": "createAlias listAliases", "label": "createAlias
listAliases", "required": false, "javaType": "String", "deprecated": false,
"autowired": false, "secret": false, "description": "For createAlias, the
function version that the alias points to, which is required. For listAliases,
only the aliases that point to this version are listed.", "constantName":
"org.apache.camel.component.aws2.lambda.La [...]
"CamelAwsLambdaAliasFunctionName": { "index": 28, "kind": "header",
"displayName": "", "group": "createAlias deleteAlias getAlias", "label":
"createAlias deleteAlias getAlias", "required": true, "javaType": "String",
"deprecated": false, "autowired": false, "secret": false, "description": "The
name of the alias. Required.", "constantName":
"org.apache.camel.component.aws2.lambda.Lambda2Constants#FUNCTION_ALIAS_NAME" },
"CamelAwsLambdaAliasFunctionDescription": { "index": 29, "kind": "header",
"displayName": "", "group": "createAlias", "label": "createAlias", "required":
false, "javaType": "String", "deprecated": false, "autowired": false, "secret":
false, "description": "The description of the alias.", "constantName":
"org.apache.camel.component.aws2.lambda.Lambda2Constants#FUNCTION_ALIAS_DESCRIPTION"
},
- "CamelAwsLambdaMarker": { "index": 30, "kind": "header", "displayName":
"", "group": "listFunctions listVersions listAliases listEventSourceMapping
listTags", "label": "listFunctions listVersions listAliases
listEventSourceMapping listTags", "required": false, "javaType": "String",
"deprecated": false, "autowired": false, "secret": false, "description": "The
pagination token. Set it to the value of this header that a previous list
returned, to get the next page. listFunctions, listVe [...]
+ "CamelAwsLambdaMarker": { "index": 30, "kind": "header", "displayName":
"", "group": "listFunctions listVersions listAliases listEventSourceMapping
listTags", "label": "listFunctions listVersions listAliases
listEventSourceMapping listTags", "required": false, "javaType": "String",
"deprecated": false, "autowired": false, "secret": false, "description": "The
pagination token. Set it to the value of this header that a previous list
returned, to get the next page. listFunctions, listVe [...]
"CamelAwsLambdaMaxItems": { "index": 31, "kind": "header", "displayName":
"", "group": "listFunctions listVersions listAliases listEventSourceMapping",
"label": "listFunctions listVersions listAliases listEventSourceMapping",
"required": false, "javaType": "Integer", "deprecated": false, "autowired":
false, "secret": false, "description": "The maximum number of items to return.
listFunctions, listVersions and listFunctionUrlConfigs return at most 50 items
per call, even if this value [...]
"CamelAwsLambdaIsTruncated": { "index": 32, "kind": "header",
"displayName": "", "group": "listFunctions listVersions listAliases
listEventSourceMapping", "label": "listFunctions listVersions listAliases
listEventSourceMapping", "required": false, "javaType": "Boolean",
"deprecated": false, "autowired": false, "secret": false, "description":
"Whether more results are available: true when the response has the token of a
next page in CamelAwsLambdaMarker.", "constantName": "org.apache. [...]
"CamelAwsLambdaFunctionArn": { "index": 33, "kind": "header",
"displayName": "", "group": "createFunction getFunction publishVersion
createAlias getAlias", "label": "createFunction getFunction publishVersion
createAlias getAlias", "required": false, "javaType": "String", "deprecated":
false, "autowired": false, "secret": false, "description": "The ARN of the
function, set by createFunction, getFunctionConfiguration,
updateFunctionConfiguration, createFunctionUrlConfig, getFunctionUrl [...]
diff --git
a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Constants.java
b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Constants.java
index f3a49ded012c..d37b3f19b872 100644
---
a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Constants.java
+++
b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Constants.java
@@ -161,8 +161,9 @@ public interface Lambda2Constants {
// Pagination constants
@Metadata(label = "listFunctions listVersions listAliases
listEventSourceMapping listTags",
description = "The pagination token. Set it to the value of this
header that a previous list returned, to get"
- + " the next page. listFunctions, listVersions,
listAliases and listFunctionUrlConfigs set it to the"
- + " token of the next page, or to null when there
are no more results.",
+ + " the next page. listFunctions, listVersions,
listAliases, listEventSourceMapping and"
+ + " listFunctionUrlConfigs set it to the token of
the next page, or to null when there are no more"
+ + " results.",
javaType = "String")
String MARKER = "CamelAwsLambdaMarker";
@Metadata(label = "listFunctions listVersions listAliases
listEventSourceMapping",
diff --git
a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index 68c01ac1bbed..c6e6d4f4f0ab 100644
---
a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++
b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -610,6 +610,14 @@ public class Lambda2Producer extends DefaultProducer {
} else {
ListEventSourceMappingsRequest.Builder builder =
ListEventSourceMappingsRequest.builder();
builder.functionName(getEndpoint().getFunction());
+ String marker = getOptionalHeader(exchange,
Lambda2Constants.MARKER, String.class);
+ if (ObjectHelper.isNotEmpty(marker)) {
+ builder.marker(marker);
+ }
+ Integer maxItems = getOptionalHeader(exchange,
Lambda2Constants.MAX_ITEMS, Integer.class);
+ if (ObjectHelper.isNotEmpty(maxItems)) {
+ builder.maxItems(maxItems);
+ }
request = builder.build();
}
try {
@@ -620,6 +628,8 @@ public class Lambda2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
+ message.setHeader(Lambda2Constants.MARKER, result.nextMarker());
+ message.setHeader(Lambda2Constants.IS_TRUNCATED,
ObjectHelper.isNotEmpty(result.nextMarker()));
}
private void listTags(LambdaClient lambdaClient, Exchange exchange) throws
InvalidPayloadException {
diff --git
a/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/AmazonLambdaClientMock.java
b/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/AmazonLambdaClientMock.java
index 404559be17c4..35b1f6349547 100644
---
a/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/AmazonLambdaClientMock.java
+++
b/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/AmazonLambdaClientMock.java
@@ -228,15 +228,29 @@ public class AmazonLambdaClientMock implements
LambdaClient {
@Override
public ListEventSourceMappingsResponse listEventSourceMappings(
ListEventSourceMappingsRequest listEventSourceMappingsRequest) {
+ // three mappings, paged with the marker (the index of the first
entry) and maxItems, like the service does
+ int total = 3;
+ int from = listEventSourceMappingsRequest.marker() == null
+ ? 0 :
Integer.parseInt(listEventSourceMappingsRequest.marker());
+ int size = listEventSourceMappingsRequest.maxItems() == null
+ ? total : listEventSourceMappingsRequest.maxItems();
+ int to = Math.min(from + size, total);
+
ListEventSourceMappingsResponse.Builder result =
ListEventSourceMappingsResponse.builder();
List<EventSourceMappingConfiguration> confList = new ArrayList<>();
- EventSourceMappingConfiguration.Builder conf =
EventSourceMappingConfiguration.builder();
- conf.batchSize(100);
- conf.functionArn("arn:aws:lambda:eu-central-1:643534317684:function:"
+ listEventSourceMappingsRequest.functionName());
- conf.state("Enabled");
- conf.eventSourceArn("arn:aws:sqs:eu-central-1:643534317684:testqueue");
- confList.add(conf.build());
+ for (int i = from; i < to; i++) {
+ EventSourceMappingConfiguration.Builder conf =
EventSourceMappingConfiguration.builder();
+ conf.batchSize(100);
+ conf.functionArn(
+ "arn:aws:lambda:eu-central-1:643534317684:function:" +
listEventSourceMappingsRequest.functionName());
+ conf.state("Enabled");
+
conf.eventSourceArn("arn:aws:sqs:eu-central-1:643534317684:testqueue" + i);
+ confList.add(conf.build());
+ }
result.eventSourceMappings(confList);
+ if (to < total) {
+ result.nextMarker(String.valueOf(to));
+ }
return result.build();
}
diff --git
a/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/LambdaProducerTest.java
b/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/LambdaProducerTest.java
index cea3bcca2672..1287adabe80e 100644
---
a/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/LambdaProducerTest.java
+++
b/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/LambdaProducerTest.java
@@ -232,6 +232,33 @@ public class LambdaProducerTest extends CamelTestSupport {
ListEventSourceMappingsResponse result =
exchange.getMessage().getBody(ListEventSourceMappingsResponse.class);
assertEquals("arn:aws:lambda:eu-central-1:643534317684:function:GetHelloWithName",
result.eventSourceMappings().get(0).functionArn());
+ assertEquals(3, result.eventSourceMappings().size());
+ assertEquals(false,
exchange.getMessage().getHeader(Lambda2Constants.IS_TRUNCATED));
+ }
+
+ @Test
+ public void lambdaListEventSourceMappingPagesWithMarkerAndMaxItems()
throws Exception {
+ Exchange firstPage = template.send("direct:listEventSourceMapping",
ExchangePattern.InOut,
+ e -> e.getIn().setHeader(Lambda2Constants.MAX_ITEMS, 2));
+ MockEndpoint.assertIsSatisfied(context);
+
+ ListEventSourceMappingsResponse first =
firstPage.getMessage().getBody(ListEventSourceMappingsResponse.class);
+ assertEquals(2, first.eventSourceMappings().size());
+ assertEquals("arn:aws:sqs:eu-central-1:643534317684:testqueue0",
first.eventSourceMappings().get(0).eventSourceArn());
+ assertEquals(true,
firstPage.getMessage().getHeader(Lambda2Constants.IS_TRUNCATED));
+ String marker =
firstPage.getMessage().getHeader(Lambda2Constants.MARKER, String.class);
+ assertNotNull(marker, "a truncated answer carries the marker of the
next page");
+
+ Exchange secondPage = template.send("direct:listEventSourceMapping",
ExchangePattern.InOut, e -> {
+ e.getIn().setHeader(Lambda2Constants.MAX_ITEMS, 2);
+ e.getIn().setHeader(Lambda2Constants.MARKER, marker);
+ });
+
+ ListEventSourceMappingsResponse second =
secondPage.getMessage().getBody(ListEventSourceMappingsResponse.class);
+ assertEquals(1, second.eventSourceMappings().size());
+ assertEquals("arn:aws:sqs:eu-central-1:643534317684:testqueue2",
+ second.eventSourceMappings().get(0).eventSourceArn());
+ assertEquals(false,
secondPage.getMessage().getHeader(Lambda2Constants.IS_TRUNCATED));
}
@Test
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Lambda2EndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Lambda2EndpointBuilderFactory.java
index 1f498c1bf558..037752355b46 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Lambda2EndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Lambda2EndpointBuilderFactory.java
@@ -1108,8 +1108,9 @@ public interface Lambda2EndpointBuilderFactory {
/**
* The pagination token. Set it to the value of this header that a
* previous list returned, to get the next page. listFunctions,
- * listVersions, listAliases and listFunctionUrlConfigs set it to the
- * token of the next page, or to null when there are no more results.
+ * listVersions, listAliases, listEventSourceMapping and
+ * listFunctionUrlConfigs set it to the token of the next page, or to
+ * null when there are no more results.
*
* The option is a: {@code String} type.
*