- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Tôi có một cái Lambda
函数,它有多个 MSK
触发器配置 - 每个都针对不同的主题。
nếu như Lambda
的输入 ( MSKEvent
) 可以包含多个不同的主题,则未在官方文档中找到任何信息。
官方文档提供了以下输入单个mytopic
主题的例子:
{
"eventSource":"aws:kafka",
"eventSourceArn":"arn:aws:kafka:sa-east-1:123456789012:cluster/vpc-2priv-2pub/751d2973-a626-431c-9d4e-d7975eb44dd7-2",
"records":{
"mytopic-0":[
{
"topic":"mytopic",
"partition":"0",
"offset":15,
"timestamp":1545084650987,
"timestampType":"CREATE_TIME",
"value":"SGVsbG8sIHRoaXMgaXMgYSB0ZXN0Lg==",
"headers":[
{
"headerKey":[
104,
101,
97,
100,
101,
114,
86,
97,
108,
117,
101
]
}
]
}
]
}
}
但尚不清楚以下具有 2 个不同主题(mytopic
,different-topic
)的示例是否可行:
{
"eventSource": "aws:kafka",
"eventSourceArn": "arn:aws:kafka:sa-east-1:123456789012:cluster/vpc-2priv-2pub/751d2973-a626-431c-9d4e-d7975eb44dd7-2",
"records": {
"mytopic-0": [
{
"topic": "mytopic",
"partition": "0",
"offset": 15,
"timestamp": 1545084650987,
"timestampType": "CREATE_TIME",
"value": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0Lg==",
"headers": [
{
"headerKey": [104, 101, 97, 100, 101, 114, 86, 97, 108, 117, 101]
}
]
}
],
"different-topic-0": [
{
"topic": "different-topic",
"partition": "0",
"offset": 15,
"timestamp": 1545084650987,
"timestampType": "CREATE_TIME",
"value": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0Lg==",
"headers": [
{
"headerKey": [104, 101, 97, 100, 101, 114, 86, 97, 108, 117, 101]
}
]
}
]
}
}
1 Câu trả lời
确实支持,你必须在单独的MSK/Kafka事件源中设置每个主题。如果您为每个事件源指定相同的消费者组名称,Lambda 甚至会使用相同的消费者组从多个主题中消费。
该事件看起来就像您在原始问题中模拟的那样。 records
顶层的字典项有一个键topic_partition
,主题也存在于每个字典项的值中的每个 Kafka 记录中。
根据我的理解,该事件是下面 Java 对象的序列化版本,它来自此处的存储库。您可以派生一个数据结构以将事件反序列化到您在 Lambda 中定位的任何平台。
另一篇文章提到在这个用例中使用 Glue (Spark Streaming)。对于大容量、大数据或分析问题,这是一个好主意。但除非您需要分布式计算解决方案,否则它可能有点矫枉过正。但消费低容量主题或不需要大量消费逻辑或分布式计算的主题非常适合 Lambda。
/*
* Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.lambda.runtime.events;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
@Dữ liệu
@NoArgsConstructor
@AllArgsConstructor
@Builder(setterPrefix = "with")
/** Represents a Kafka Event. **/
public class KafkaEvent {
private Map> records;
private String eventSource;
private String eventSourceArn;
private String bootstrapServers;
@Dữ liệu
@NoArgsConstructor
@AllArgsConstructor
@Builder(setterPrefix = "with")
public static class KafkaEventRecord {
private String topic;
private int partition;
private long offset;
private long timestamp;
private String timestampType;
private String key;
private String value;
private List<>> headers;
}
@Dữ liệu
@NoArgsConstructor
@AllArgsConstructor
@Builder(setterPrefix = "with")
public static class TopicPartition {
private String topic;
private int partition;
@Ghi đè
public String toString() {
//Kafka also uses '-' for toString()
return topic + "-" + partition;
}
}
}
关于aws-lambda - AWS Lambda 的 AWS MSK 触发器 - 同一执行上下文中的多个主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71099655/
可以使用 lambda 和函数创建有序对(Lisp 中的缺点),如 Use of lambda for cons/car/cdr definition in SICP 所示。 它也适用于 Python
我正在尝试从另一个调用一个 AWS lambda 并执行 lambda 链接。这样做的理由是 AWS 不提供来自同一个 S3 存储桶的多个触发器。 我创建了一个带有 s3 触发器的 lambda。第一
根据以下源代码,常规 lambda 似乎可以与扩展 lambda 互换。 fun main(args: Array) { val numbers = listOf(1, 2, 3) f
A Tutorial Introduction to the Lambda Calculus 本文介绍乘法函数 The multiplication of two numbers x and y ca
我想弄清楚如何为下面的表达式绘制语法树。首先,这究竟是如何表现的?看样子是以1和2为参数,如果n是 0,它只会返回 m . 另外,有人可以指出解析树的开始,还是一个例子?我一直找不到一个。 最佳答案
在 C++0x 中,我想知道 lambda 函数的类型是什么。具体来说: #include type1 foo(int x){ return [x](int y)->int{return x * y
我在其中一个职位发布中看到了这个问题,它询问什么是 lambda 函数以及它与高阶函数的关系。我已经知道如何使用 lambda 函数,但不太自信地解释它,所以我做了一点谷歌搜索,发现了这个:What
Thật khó để biết câu hỏi ở đây là gì. Câu hỏi này mơ hồ, không rõ ràng, không đầy đủ, quá rộng hoặc mang tính tu từ và không thể trả lời hợp lý theo hình thức hiện tại. Để được trợ giúp làm rõ vấn đề này để bạn có thể mở lại, hãy truy cập trung tâm trợ giúp. Đã đóng
Evaluate (((lambda(x y) (lambda (x) (* x y))) 5 6) 10) in Scheme. 我不知道实际上该怎么做! ((lambda (x y) (+ x x
我正在处理 MyCustomType 的实例集合如下: fun runAll(vararg commands: MyCustomType){ commands.forEach { it.myM
Brian 在他对问题 "Are side effects a good thing?" 的论证中的前提很有趣: computers are von-Neumann machines that are
在 Common Lisp 中,如果我希望两个函数共享状态,我将按如下方式执行 let over lambda: (let ((state 1)) (defun inc-state () (in
Evaluate (((lambda(x y) (lambda (x) (* x y))) 5 6) 10) in Scheme. 我不知道实际上该怎么做! ((lambda (x y) (+ x x
作为lambda calculus wiki说: There are several possible ways to define the natural numbers in lambda cal
我有一个数据类,我需要初始化一些 List .我需要获取 JsonArray 的值(我使用的是 Gson)。 我做了这个函数: private fun arrayToList(data: JsonAr
((lambda () )) 的方案中是否有简写 例如,代替 ((lambda () (define x 1) (display x))) 我希望能够做类似的事情 (empty-lam
我在 Java library 中有以下方法: public void setColumnComparator(final int columnIndex, final Comparator colu
我正在研究一个函数来计算国际象棋游戏中棋子的有效移动。 white-pawn-move 函数有效。当我试图将其概括为任一玩家的棋子 (pawn-move) 时,我遇到了非法函数调用。我已经在 repl
考虑这段代码(在 GCC 和 MSVC 上编译): int main() { auto foo = [](auto p){ typedef decltype(p) p_t;
我正在阅读一个在 lambda 内部使用 lambda 的片段,然后我想通过创建一个虚拟函数来测试它,该函数从文件中读取然后返回最大和最小数字。 这是我想出来的 dummy = lambda path
Tôi là một lập trình viên xuất sắc, rất giỏi!