简体   繁体   English

如何在批处理消费者模式下将 Kinesis 标头传递给 Spring Cloud Stream 函数?

[英]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.

相关问题 如何将自定义 header 从 spring-cloud-stream(aws kinesis binder)发送到“旧版”spring 集成消费者 - How to send custom header from spring-cloud-stream (aws kinesis binder) to "legacy" spring integration consumer 带有 kafka 消费者的 Spring Cloud Stream 3.0 在批处理模式下获取列表中的单个记录而不是更多 - Spring Cloud Stream 3.0 with kafka consumer in batch mode fetches single record in list instead of more 春季云流运动学配置 - spring cloud stream kinesis configuration 消费者不会收到Spring Cloud流活页夹Kafka自定义标头 - Spring Cloud stream binder Kafka custom headers are not received in consumer Spring Cloud Stream Kinesis 消费者组可以由非 Spring 生产者发送吗? - Can a Spring Cloud Stream Kinesis consumer group be sent by a non-Spring producer? 春云流kinesis宾德 - spring cloud stream kinesis Binder 如何禁用 Spring 云 Stream Kafka 消费者 - How to disable a Spring Cloud Stream Kafka consumer 如何在 spring-cloud-stream-binder-kinesis 中使用 STSAssumeRoleSessionCredentialsProvider 进行配置 - How to Configure using STSAssumeRoleSessionCredentialsProvider in spring-cloud-stream-binder-kinesis 如何暂停消费者在 Spring Cloud kinesis 流中消费消息 - How to pause consumers from consuming messages in spring cloud kinesis stream Spring 云 Stream 消费者启动 - Spring Cloud Stream consumer startup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM