Last active
April 24, 2018 02:24
-
-
Save ridwanbejo/9c01b05500136bf187fbc929081601fd to your computer and use it in GitHub Desktop.
producer for clickstream tracker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var QUEUE_URL = '<url>/clickstreamQueueDev'; | |
var AWS = require('aws-sdk'); | |
var sqs = new AWS.SQS({region : 'ap-northeast-1'}); | |
exports.handler = function(event, context, callback) { | |
var params = { | |
MessageBody: event.body, | |
QueueUrl: QUEUE_URL | |
}; | |
sqs.sendMessage(params, function(err, data){ | |
if(err) { | |
console.log('error:',"Fail Send Message" + err); | |
callback(null, { statusCode: 400, body: '{"message":"Failed to queue the message!"}' }); | |
}else{ | |
console.log('data:',data.MessageId); | |
callback(null, { statusCode: 200, body: '{"message":"Success!"}' }); | |
} | |
}); | |
// console.log(event.body); | |
// callback(null, { statusCode: 200, body: '{"message":"Success!"}' }); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment