Skip to content

Commit 7e0ee4c

Browse files
committed
remove fluent api support for batch
1 parent c8528ba commit 7e0ee4c

21 files changed

+3
-3662
lines changed

docs/utilities/batch-processing.md

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ stateDiagram-v2
3636
- Typed batch processing with automatic deserialization
3737
- Lambda context injection for typed handlers
3838
- AOT (Ahead-of-Time) compilation support
39-
- Fluent API for inline handler configuration
39+
4040
- Bring your own batch processor
4141
- Parallel processing
4242

@@ -357,53 +357,9 @@ Processing batches from SQS using Lambda handler decorator works in three stages
357357
When using [SQS FIFO queues](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html){target="_blank"}, we will stop processing messages after the first failure, and return all failed and unprocessed messages in `batchItemFailures`.
358358
This helps preserve the ordering of messages in your queue. Powertools automatically detects a FIFO queue.
359359

360-
#### Using Fluent API with Typed Handlers
361-
362-
You can also use the fluent API for more flexible inline handler configuration:
363-
364-
=== "Function.cs"
365-
366-
```csharp hl_lines="3-13"
367-
public async Task<BatchItemFailuresResponse> HandlerUsingFluentApi(SQSEvent sqsEvent, ILambdaContext context)
368-
{
369-
var result = await TypedSqsBatchProcessor.Instance
370-
.Handler<Product>((product, ct) =>
371-
{
372-
Logger.LogInformation($"Processing product {product.Id} - {product.Name}");
373-
374-
if (product.Price < 0)
375-
throw new ArgumentException("Invalid product price");
376360

377-
return Task.FromResult(RecordHandlerResult.None);
378-
})
379-
.ProcessAsync(sqsEvent, context);
380-
381-
return result.BatchItemFailuresResponse;
382-
}
383-
```
384-
385-
#### Using Fluent API with Lambda Context
386-
387-
For handlers that need access to Lambda context:
388-
389-
=== "Function.cs"
390-
391-
```csharp hl_lines="3-11"
392-
public async Task<BatchItemFailuresResponse> HandlerWithContext(SQSEvent sqsEvent, ILambdaContext context)
393-
{
394-
var result = await TypedSqsBatchProcessor.Instance
395-
.Handler<Product>((product, lambdaContext, ct) =>
396-
{
397-
Logger.LogInformation($"Processing product {product.Id} in request {lambdaContext.AwsRequestId}");
398-
Logger.LogInformation($"Remaining time: {lambdaContext.RemainingTime.TotalSeconds}s");
399361

400-
return Task.FromResult(RecordHandlerResult.None);
401-
})
402-
.ProcessAsync(sqsEvent, context);
403362

404-
return result.BatchItemFailuresResponse;
405-
}
406-
```
407363

408364
### Processing messages from Kinesis
409365

@@ -1032,23 +988,7 @@ For Native AOT scenarios, you can configure JsonSerializerContext:
1032988
}
1033989
```
1034990

1035-
=== "Using with Fluent API"
1036-
1037-
```csharp hl_lines="3"
1038-
public async Task<BatchItemFailuresResponse> ProcessWithAot(SQSEvent sqsEvent, ILambdaContext context)
1039-
{
1040-
var result = await TypedSqsBatchProcessor.Instance
1041-
.WithJsonSerializerContext(MyJsonSerializerContext.Default)
1042-
.Handler<Product>((product, ct) =>
1043-
{
1044-
Logger.LogInformation($"AOT processing product {product.Id}");
1045-
return Task.FromResult(RecordHandlerResult.None);
1046-
})
1047-
.ProcessAsync(sqsEvent, context);
1048991

1049-
return result.BatchItemFailuresResponse;
1050-
}
1051-
```
1052992

1053993
### Lambda Context Injection
1054994

@@ -1144,24 +1084,6 @@ You can gradually migrate from traditional to typed handlers:
11441084

11451085
Typed processors support the same error handling policies as traditional processors:
11461086

1147-
=== "Deserialization Error Handling"
1148-
1149-
```csharp hl_lines="3"
1150-
public async Task<BatchItemFailuresResponse> HandleWithErrorPolicy(SQSEvent sqsEvent, ILambdaContext context)
1151-
{
1152-
var result = await TypedSqsBatchProcessor.Instance
1153-
.IgnoreDeserializationErrors(false) // Fail on deserialization errors (default)
1154-
.Handler<Product>((product, ct) =>
1155-
{
1156-
Logger.LogInformation($"Processing product {product.Id}");
1157-
return Task.FromResult(RecordHandlerResult.None);
1158-
})
1159-
.ProcessAsync(sqsEvent, context);
1160-
1161-
return result.BatchItemFailuresResponse;
1162-
}
1163-
```
1164-
11651087
=== "Custom Error Handling"
11661088

11671089
```csharp hl_lines="2"

libraries/src/AWS.Lambda.Powertools.BatchProcessing/BatchProcessorAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ internal IBatchProcessingAspectHandler CreateAspectHandler(IReadOnlyList<object>
302302
// Check if typed handlers are configured (not yet fully supported in attributes)
303303
if (IsTypedHandlerConfigured())
304304
{
305-
throw new NotSupportedException("Typed record handlers are not yet fully supported with BatchProcessorAttribute. Please use the fluent API or direct typed batch processor calls for typed processing.");
305+
throw new NotSupportedException("Typed record handlers are not yet fully supported with BatchProcessorAttribute. Please use direct typed batch processor calls for typed processing.");
306306
}
307307

308308
// Create aspect handler

0 commit comments

Comments
 (0)