Created
August 19, 2015 07:22
-
-
Save id0Sch/edd473397feb8dda86ea to your computer and use it in GitHub Desktop.
This file contains hidden or 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
self.dispatchInternal = function (queue, message) { | |
return self.connection.getQueue(queue) | |
.then(function (queue) { | |
return self.connection.sendMessageAsync({ | |
MessageBody: JSON.stringify(message), | |
QueueUrl: queue.QueueUrl | |
}); | |
}) | |
.then(function (message) { | |
self.logger.debug(util.format("dispatched new event: %s, message Id: %s", queue, message.MessageId)); | |
}) | |
.catch(function (e) { | |
self.logger.error("Dispatch failure: %s", e.toString()); | |
}); | |
}; | |
self.dispatch = function (queue, message) { | |
return Promise.each(_.isString(queue) ? [queue] : queue, function (queueItem) { | |
return self.dispatchInternal(queueItem, message); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment