简体   繁体   English

在 AWS Kinesis 上从外部 API 推送数据

[英]Push data from external API on AWS Kinesis

I am new to AWS ecosystem.我是 AWS 生态系统的新手。 I'm building a (near) real-time system, where data comes from external API.我正在构建一个(近乎)实时系统,其中数据来自外部 API。 The API is updated every 10 seconds, so I would like to consume and populate my Kinesis pipeline as soon as new data appears. API 每 10 秒更新一次,所以我想在新数据出现后立即使用和填充我的 Kinesis 管道。 However, I'm not sure which tool use for that.但是,我不确定使用哪种工具。 I did a small research and, I think, I have two options:我做了一个小的研究,我认为,我有两个选择:

  • AWS lambda which is triggered every 10 seconds and puts data on Kinesis AWS lambda 每 10 秒触发一次,并将数据放在 Kinesis 上
  • AWS StepFunction AWS StepFunction

What is the standard approach for a given use case?给定用例的标准方法是什么?

AWS Step functions is created by Lambda functions. AWS Step 函数由 Lambda 函数创建。 That is, each step in a workflow is actually a Lambda function.也就是说,工作流中的每一步实际上都是一个 Lambda function。 You can think of a workflow created by AWS Step Functions as a chain of Lambda functions.您可以将 AWS Step Functions 创建的工作流视为 Lambda 函数链。

If you are not familiar with how to create a workflow see this AWS tutorial:如果您不熟悉如何创建工作流程,请参阅此 AWS 教程:

Create AWS serverless workflows by using the AWS SDK for Java 使用适用于 Java 的 AWS SDK 创建 AWS 无服务器工作流

(you can create a Lambda function in any supported programming language. This one happens to use Java). (您可以使用任何支持的编程语言创建 Lambda function。这个恰好使用 Java)。

Now, to answer your question, using a workflow to populate a Kinesis data stream is possible.现在,要回答您的问题,可以使用工作流填充 Kinesis 数据 stream。 You can build a Lambda function that gathers data (using logic in your Lambda function), and then invoke the putRecord operation of Kinesis to populate the data stream. You can build a Lambda function that gathers data (using logic in your Lambda function), and then invoke the putRecord operation of Kinesis to populate the data stream. You can create a scheduled event that fires off every x min based on a CRON expression.您可以创建一个基于 CRON 表达式每 x 分钟触发一次的计划事件。

If you do use a CRON expression, you can use the AWS Step Functions API to fire off the workflow.如果您确实使用 CRON 表达式,则可以使用 AWS Step Functions API 来启动工作流。 That is, create another Lambda function that is scheduled to fire say every 10 mins.也就是说,创建另一个 Lambda function 计划每 10 分钟触发一次。 Then in this Lambda funciton, use the Step Functions API to invoke the workflow.然后在此 Lambda 函数中,使用 Step Functions API 调用工作流。 Now the workflow can populate the Kinesis data stream with data.现在,工作流可以使用数据填充 Kinesis 数据 stream。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM