[英]How do you pass Kinesis headers to Spring Cloud Stream functions in batch consumer mode?
I am in the process of converting our existing stream processing code that currently uses the annotation-based programming model to use Spring Cloud Function instead.我正在将当前使用基于注释的编程模型的现有流处理代码转换为使用 Spring Cloud Function。 With consumer batch mode enabled, how can I pass the AWS Kinesis checkpointer to my
Consumer
so that only after the processor has successfully processed all of the messages in the batch do I perform the manual checkpoint operation?启用消费者批处理模式后,如何将 AWS Kinesis 检查点传递给我的
Consumer
,以便只有在处理器成功处理批处理中的所有消息后,我才能执行手动检查点操作? Using the annotation-based programming model, I am easily able to pass in the checkpointer using the @Header
annotation.使用基于注解的编程模型,我可以很容易地使用
@Header
注解传入检查指针。 Will this approach still work as I have depicted in the following code snippet?正如我在以下代码片段中所描述的那样,这种方法是否仍然有效?
@Retryable(
include = {ServerException.class},
maxAttemptsExpression = "#{@myProperties.getRetry().getMaxAttempts()}",
backoff = @Backoff(delayExpression = "#{@myProperties.getRetry().getDelay()}"))
public Consumer<List<byte[]>> processStream(
@Header(AwsHeaders.CHECKPOINTER) final IRecordProcessorCheckpointer checkpointer) {
return m -> {
try {
myProcessor.process(m);
} catch (final Exception e) {
log.error("An error occurred processing the log messages", e);
throw new ServerException(HttpStatus.INTERNAL_SERVER_ERROR, e);
}
checkpoint(checkpointer);
};
}
No. The signature of your Consumer
must be a Message<List<byte[]>>
.不,您的
Consumer
的签名必须是Message<List<byte[]>>
。 so then you can call message.getHeaders().get(AwsHeaders.CHECKPOINTER, IRecordProcessorCheckpointer.class)
那么你可以调用
message.getHeaders().get(AwsHeaders.CHECKPOINTER, IRecordProcessorCheckpointer.class)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.