Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js AWS Lambda-未调用PutItem Dynamo DB回调_Node.js_Amazon Web Services_Apache Kafka_Aws Lambda_Amazon Dynamodb - Fatal编程技术网

Node.js AWS Lambda-未调用PutItem Dynamo DB回调

Node.js AWS Lambda-未调用PutItem Dynamo DB回调,node.js,amazon-web-services,apache-kafka,aws-lambda,amazon-dynamodb,Node.js,Amazon Web Services,Apache Kafka,Aws Lambda,Amazon Dynamodb,我试着去听卡夫卡和消费信息(作品) 但是从未调用putItem()的回调,因此语句: log(“你好,世界!!!!”) 从不露面。 可能是什么问题?您对DynamoDB的请求超时,因为您正在VPC中运行Lambda功能,但您没有提供NAT网关或允许Lambda功能访问VPC之外的DynamoDB的网关 我建议将VPC端点配置为DynamoDB。您能否确认数据实际上已插入到DynamoDB表中?事实并非如此@MarkBYou是对的,我们缺少DynamoDB的权限。这是无声的暂停 exports.h

我试着去听卡夫卡和消费信息(作品)

但是从未调用putItem()的回调,因此语句: log(“你好,世界!!!!”)

从不露面。
可能是什么问题?

您对DynamoDB的请求超时,因为您正在VPC中运行Lambda功能,但您没有提供NAT网关或允许Lambda功能访问VPC之外的DynamoDB的网关


我建议将VPC端点配置为DynamoDB。

您能否确认数据实际上已插入到DynamoDB表中?事实并非如此@MarkBYou是对的,我们缺少DynamoDB的权限。这是无声的暂停
exports.handler = function(event, context) {
    var AWS = require('aws-sdk');
    var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
    var kafka = require('kafka-node');
    var Consumer = kafka.Consumer,
        // The client specifies the ip of the Kafka producer and uses
        // the zookeeper port 2181
        client = new kafka.KafkaClient({kafkaHost: '172.16.35.115:9092,172.16.35.217:9092,172.16.37.14:9092'});



        // The consumer object specifies the client and topic(s) it subscribes to
        consumer = new Consumer( client, [ { topic: 'BillKazTopic', partition: 0, fromOffset: 'latest'} ], { autoCommit: true });
        consumer.on('message', function (message) {
            console.log("hellow");
            console.log(message);

            // Add to Dynamo
            var tableName = "dev-AM-Appointment";   
            console.log(JSON.stringify(event, null, '  ')); 
            dynamodb.putItem({
                "TableName": tableName,
                "Item" : {
                    "appointment_id": {S: 'message=' + message.value}
                }
            }, function(err, data) {
                console.log("HELLO WORLD!!!!");
                if (err) {
                    console.log('Error putting item into dynamodb failed: '+err);
                    context.succeed('error');
                }
                else {
                    console.log('great success: '+JSON.stringify(data, null, '  '));
                    context.succeed('Done');
                }
            }); 

        });
};