Skip to content

Instantly share code, notes, and snippets.

@ridwanbejo
Last active April 24, 2018 02:24
Show Gist options
  • Save ridwanbejo/9c01b05500136bf187fbc929081601fd to your computer and use it in GitHub Desktop.
Save ridwanbejo/9c01b05500136bf187fbc929081601fd to your computer and use it in GitHub Desktop.
producer for clickstream tracker
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